From the Idea to the App — Episode 2

Thimo Bess
arconsis
Published in
2 min readJul 23, 2021

In today’s episode we start with our first real feature: The movie search.
For this, we’ll consider implementations for the first API request against the database we’re using (https://www.themoviedb.org).

We start by looking at the data structure of the API and creating the first client-side data models. For the first version we will limit ourselves to a fraction of the information actually provided, later we will certainly extend this.

So for now a movie looks like this:

With the help of this model we can now start to implement our first request.
We use the Combine Framework from Apple (https://developer.apple.com/documentation/combine).

Our search function looks like this:

In step 1 we define the URL of the request. We do this with the help of URLComponents.
The API requires an API key, which must be supplied as a URL parameter.

The response is in JSON format, so in step 2 we need a JSON decoder to create a Swift object from the JSON string.

In step 3, we create a URLSession for ourselves and thenwe can execute the request.

Finally, in step 4 we execute the request and convert the response into our Swift object.

If you want to know all the details, you can watch the full session here:

The complete project can be found on Github

--

--