How to Build a Movie Database & API with Strapi

How to Build a Movie Database & API with Strapi

Strapi is an awesome headless CMS built with Node.js that can speed up the process of building an API quiet dramatically. It's perfect for people who enjoy the frontend more than the backend, and it allows you to build complex database structures with out writing any code. Magic, if you ask me.

To visualize the potential of Strapi I thought that we would create a Movie Database & API. I chose this concept instead of a classic "Blog" tutorial as I thought it would better showcase the Strapi's capabilities.

A movie database needs a few things to be useful. We need Movies and Genres, but to make things a little more interesting we could add Actors and Directors.

To follow along in this tutorial there are a few requirement that you should know of. Strapi requires a package manager (NPM or Yarn) and Node.js to operate.

  • Node.js >= 10.x
  • NPM >= 6.x

Install Strapi

Open up your terminal on your computer and navigate to the directory where you want to install your project.

cd directoryname

Strapi can be installed via two package managers, NPM and Yarn. I personally enjoy NPM but the choice is up to you.

#NPM
npx create-strapi-app moviedb --quickstart
#Yarn
yarn create strapi-app moviedb --quickstart

Once your installation is complete you can navigate to http://localhost:1337/admin and create an admin user account.

Create Strapi Admin Account

How to Build a Movie Database & API with Strapi

As soon as you have created your admin account you get greeted by the Strapi's beautiful admin panel.

Since we flagged our project with the --quickstart flag during the installation our project comes preconfigured with SQLite as our database, as well as a few plugins installed by default.

The Content Type Builder, File Uploads and Roles & Permissions are some of those plugins that was installed and we will make use of all of them during this tutorial.

But first we will take a look at the Content Type Builder as it is the bread and butter of Strapi.

With the Content Type Builder you can create database models and specify fields and relations. Strapi will then automatically generate API endpoints for each Content Type (without you writing any code). It's pretty cool, if you ask me.

Create Content Types & Fields

As we are building a Movie Database we will need a few different content types to make things a little more interesting.

  • Movies
  • Genres
  • Actors
  • Directors

Navigate to the Content Type Builder and click Create new content-type.

A movie will need some specific fields to display valuable information for our API, let's start with the basic once.

Movies

  • Title (text field) - the name of the movie.
  • Thumbnail (media field) - will handle uploads of a movie poster.
  • Description (rich text field) will house information about the movie.

Add the fields specified above to your Movies Content Type.

Create Movies Schema

When you are done adding the fields click the green save button in the top-right corner. This will take some time as Strapi is creating the database models and corresponding fields.

Strapi Wait for Restart

Your Movies Content Type should now contain the following fields.

Movies Fields

As you can see we now have a new Content Type called movie in our left sidebar, awesome.

We repeat this process for all the other necessary Content Types.

Genres

  • Title (text field) - will be the name of the genre.
  • Description - a description of the genre.

Genress Fields

Actors

  • Name (text field) - Name of the actor.
  • Thumbnail (media field) - will handle uploads of an image of the actor.
  • Description - a description of the genre.

Actors Fields

Directors

  • Name (text field) - Name of the director.
  • Thumbnail (media field) - will handle uploads of an image of the director.
  • Description - a description of the genre.

Directors Fields

API Endpoints & Permissions

Good Stuff, the foundation of our API is done, let's have a look at our newly created API Endpoints.

http://localhost:1337/movies

Most certainly you will receive a 403 forbidden when you visit the url.

{"statusCode":403, "error":"Forbidden", "message":"Forbidden"}

Don't worry though, it's actually a good sign, it means that your endpoints are protected.

To fix this you need to make the endpoint available for public consumption.

We can do that in Strapi's admin panel under Roles & Permissions.

Click the Public profile and add permissions for "find" and "findone" on each of the content types.

Strapi Permissions

"find" represents permission for the list:

http://localhost:1337/movies

"findone" represents permissions for each individual item:

http://localhost:1337/movies/12

Navigate back to your API Endpoint now.

As you can see, we no longer receive the error 403 forbidden, instead we get an empty array. Awesome!

[]

Your API is now available for public consumption. But don't just take my word for it, add a movie yourself and you can see that the movies are added to the API.

{
    "id": 1,
    "Title": "Fury",
    "Description": "A grizzled tank commander makes tough decisions as he and his crew fight their way across Germany in April, 1945.",
    "created_at": "2020-02-07T10:56:55.724Z",
    "updated_at": "2020-02-07T10:56:55.724Z",
    "Thumbnail": [
        {
            "id": 1,
            "name": "fury.jpg",
            "hash": "fd3d650cede946dd866aa1bb752323ab",
            "sha256": "sUNwNj4bdfXoKKMROBTwbMY6gBXIW8m5BR7PpVuAang",
            "ext": ".jpg",
            "mime": "image/jpeg",
            "size": 88.22,
            "url": "/uploads/fd3d650cede946dd866aa1bb752323ab.jpg",
            "provider": "local",
            "provider_metadata": null,
            "created_at": "2020-02-07T10:56:55.799Z",
            "updated_at": "2020-02-07T10:56:55.799Z"
        }
    ],
}

Strapi & Relationships

The power of relational databases lies in the ability to form relationships between entries, hence the name relational database. Rather than writing everything over and over again relationships can help us make things less redundant.

For example, rather than writing each actor and director into a field into the move content type (database table) we create a table that will house actor and one for directors, and then link them to each movie. This way we don't have to repeat our self for each and every movie, rather just select actors and directors from a dropdown list.

The power of relationships does not stop there. What if you want to show all movies directed by a specific director? Well the relationships got you covered here as well. Imagine if you had to write each director page by hand, and how hard it would be to keep up with each new movie release for every director, or actor for that matter.

There are a few types of relationships that has their own use-cases and their own unique power. Foreign Keys, OneToOne, OneToMany, ManyToOne and ManyToMany Relationships.

In Strapi they are named accordingly:

has one relationship
has and belongs to one relationship
belongs to many relationship
has many relationship (forward)
has and belongs to many relationship
has many relationship (backwards)

You can use these types of relationships by adding a relationship field to your Content Types.

Specifying what type of relationship it is and point it between the selected content types.

When you save your field, Strapi will automatically create pivot tables and handle everything for you in the background. That is drastic improvement for people who don't enjoy spending time writing backend code, schema and handle migrations.

To seasoned developer there might still be some limitation to this magic, but for the average frontend developer and content creator it's a complete game-changer.

Lets create the necessary relationships for our Movie Database.

The Movies content type needs "has and belongs to many" relationships with the with the Actors, Directors and Genres Content Type.

Add a "has and belongs to many" relationship field from Movies to Actors ![Strapi "has and belongs to many" Relationship](https://images.tute.io/tute/upload/strapi-moviedb-api-relationship-movie-actors.png "Strapi "has and belongs to many" Relationship")

Add a "has and belongs to many" relationship field from Movies to Directors ![Strapi "has and belongs to many" Relationship](https://images.tute.io/tute/upload/strapi-moviedb-api-relationship-movie-directors.png "Strapi "has and belongs to many" Relationship")

Add a "has and belongs to many" relationship field from Movies to Genres ![Strapi "has and belongs to many" Relationship](https://images.tute.io/tute/upload/strapi-moviedb-api-relationship-movie-genres.png "Strapi "has and belongs to many" Relationship")

Usually when adding mock data I would use some sort of Faker library that automatically populates data into both fields and its relations. However, since its the first time ever using Strapi I am not aware of such library, so I added it manually.

I guess its good since it will make this tutorial more readable to people used to creating APIs in the first place.

I will not go into detail on how I add the data though. If you have added data into any type of forms on the web before, you should be good to go.

So go ahead and add Genres, Actors, Directors, and finally Movies to your liking. Mock Actors Data

As you can see, we can now add movies and simply selecting the Actors, Directors and Genre that is already in our database. Mock Movies Data

http://localhost:1337/movies/

[
    {
        "id": 1,
        "Title": "Fury",
        "Description": "A grizzled tank commander makes tough decisions as he and his crew fight their way across Germany in April, 1945.",
        "created_at": "2020-02-07T10:56:55.724Z",
        "updated_at": "2020-02-07T10:56:55.724Z",
        "Thumbnail": [
            {
                "id": 1,
                "name": "fury.jpg",
                "hash": "fd3d650cede946dd866aa1bb752323ab",
                "sha256": "sUNwNj4bdfXoKKMROBTwbMY6gBXIW8m5BR7PpVuAang",
                "ext": ".jpg",
                "mime": "image/jpeg",
                "size": 88.22,
                "url": "/uploads/fd3d650cede946dd866aa1bb752323ab.jpg",
                "provider": "local",
                "provider_metadata": null,
                "created_at": "2020-02-07T10:56:55.799Z",
                "updated_at": "2020-02-07T10:56:55.799Z"
            }
        ],
        "actors": [
            {
                "id": 1,
                "Name": "Brad Pitt",
                "Description": "William Bradley Pitt is an American actor and film producer. He has received multiple awards, including two Golden Globe Awards for his acting, and an Academy Award and a Primetime Emmy Award as producer under his production company, Plan B Entertainment.",
                "created_at": "2020-02-07T12:14:29.664Z",
                "updated_at": "2020-02-07T12:14:29.664Z",
                "Thumbnail": [
                    {
                        "id": 2,
                        "name": "brad-pitt.jpg",
                        "hash": "64a9739501da43fa96297e77deba9127",
                        "sha256": "QU66_MQhGCofQCxcbtZ8qtjCbZFEwIS8aixAadYYH8I",
                        "ext": ".jpg",
                        "mime": "image/jpeg",
                        "size": 312.9,
                        "url": "/uploads/64a9739501da43fa96297e77deba9127.jpg",
                        "provider": "local",
                        "provider_metadata": null,
                        "created_at": "2020-02-07T12:14:29.744Z",
                        "updated_at": "2020-02-07T12:14:29.744Z"
                    }
                ]
            },
            {
                "id": 3,
                "Name": "Shia Labeouf",
                "Description": "Shia Saide LaBeouf is an American actor, performance artist, and filmmaker. He became known among younger audiences as Louis Stevens in the Disney Channel series Even Stevens, a role for which LaBeouf received a Young Artist Award nomination in 2001 and won a Daytime Emmy Award in 2003.",
                "created_at": "2020-02-07T12:33:57.216Z",
                "updated_at": "2020-02-07T12:33:57.216Z",
                "Thumbnail": [
                    {
                        "id": 4,
                        "name": "shia-lebeouf.jpeg",
                        "hash": "31bcdc49c8cb4d009506809eab66a146",
                        "sha256": "ooBzoBb0HHao-i8hy9c-UD41CzmAvOniLF10Vaa5Ezo",
                        "ext": ".jpeg",
                        "mime": "image/jpeg",
                        "size": 100.66,
                        "url": "/uploads/31bcdc49c8cb4d009506809eab66a146.jpeg",
                        "provider": "local",
                        "provider_metadata": null,
                        "created_at": "2020-02-07T12:33:57.275Z",
                        "updated_at": "2020-02-07T12:33:57.275Z"
                    }
                ]
            }
        ],
        "directors": [
            {
                "id": 2,
                "Name": "David Ayer",
                "Description": "David Ayer is an American film director, producer and screenwriter. He wrote Training Day, co-wrote The Fast and the Furious, and directed Harsh Times, Street Kings, End of Watch, Sabotage, Fury, Suicide Squad and Bright.",
                "created_at": "2020-02-07T12:39:27.058Z",
                "updated_at": "2020-02-07T12:39:27.058Z",
                "Thumbnail": []
            }
        ],
        "genres": [
            {
                "id": 1,
                "Title": "Action",
                "Description": null,
                "created_at": "2020-02-07T12:10:56.599Z",
                "updated_at": "2020-02-07T12:10:56.599Z"
            },
            {
                "id": 5,
                "Title": "War",
                "Description": null,
                "created_at": "2020-02-07T12:11:59.157Z",
                "updated_at": "2020-02-07T12:11:59.157Z"
            }
        ]
    },
    {
        "id": 2,
        "Title": "Salt",
        "Description": "CIA agent Evelyn Salt's life takes an ugly turn when she is accused of planning the assassination of the Russian president. However, she flees and sets out to prove her innocence.",
        "created_at": "2020-02-07T14:17:52.048Z",
        "updated_at": "2020-02-07T14:17:52.048Z",
        "Thumbnail": [
            {
                "id": 5,
                "name": "salt.jpeg",
                "hash": "a6e0dcd61f724e8481cae53a76f16803",
                "sha256": "eUSaONZSxatrDROoJJ1Zr1g81YFexNJtMk1Y8w_zRjo",
                "ext": ".jpeg",
                "mime": "image/jpeg",
                "size": 5.88,
                "url": "/uploads/a6e0dcd61f724e8481cae53a76f16803.jpeg",
                "provider": "local",
                "provider_metadata": null,
                "created_at": "2020-02-07T14:17:52.149Z",
                "updated_at": "2020-02-07T14:17:52.149Z"
            }
        ],
        "actors": [
            {
                "id": 2,
                "Name": "Angelina Jolie",
                "Description": "Angelina Jolie is an American actress, filmmaker, and humanitarian. The recipient of such accolades as an Academy Award and three Golden Globe Awards, she has been named Hollywood's highest-paid actress multiple times.",
                "created_at": "2020-02-07T12:29:52.506Z",
                "updated_at": "2020-02-07T12:29:52.506Z",
                "Thumbnail": [
                    {
                        "id": 3,
                        "name": "angelina-jolie.jpg",
                        "hash": "4a2244aa027948fb9f4980062219db34",
                        "sha256": "ebKbAgauLj0VSPvnTQMBbMUaMa7hO2zg5f1qKK2t5Kg",
                        "ext": ".jpg",
                        "mime": "image/jpeg",
                        "size": 778.6,
                        "url": "/uploads/4a2244aa027948fb9f4980062219db34.jpg",
                        "provider": "local",
                        "provider_metadata": null,
                        "created_at": "2020-02-07T12:29:52.579Z",
                        "updated_at": "2020-02-07T12:29:52.579Z"
                    }
                ]
            }
        ],
        "directors": [
            {
                "id": 1,
                "Name": "Phillip Noyce",
                "Description": "Phillip Noyce is an Australian director, producer, and screenwriter of film and television. Since 1977, he has directed over 19 feature films in various genres, including historical drama, thrillers, and action films. He has also directed the Jack Ryan adaptations Patriot Games and Clear and Present Danger and the 2014 adaptation of Lois Lowry's The Giver.",
                "created_at": "2020-02-07T12:37:55.677Z",
                "updated_at": "2020-02-07T12:37:55.677Z",
                "Thumbnail": []
            }
        ],
        "genres": [
            {
                "id": 1,
                "Title": "Action",
                "Description": null,
                "created_at": "2020-02-07T12:10:56.599Z",
                "updated_at": "2020-02-07T12:10:56.599Z"
            },
            {
                "id": 6,
                "Title": "Mystery",
                "Description": null,
                "created_at": "2020-02-07T12:28:10.558Z",
                "updated_at": "2020-02-07T12:28:10.558Z"
            },
            {
                "id": 4,
                "Title": "Thriller",
                "Description": null,
                "created_at": "2020-02-07T12:11:49.750Z",
                "updated_at": "2020-02-07T12:11:49.750Z"
            }
        ]
    }
]

http://localhost:1337/movies/1

{
    "id": 1,
    "Title": "Fury",
    "Description": "A grizzled tank commander makes tough decisions as he and his crew fight their way across Germany in April, 1945.",
    "created_at": "2020-02-07T10:56:55.724Z",
    "updated_at": "2020-02-07T10:56:55.724Z",
    "Thumbnail": [
        {
            "id": 1,
            "name": "fury.jpg",
            "hash": "fd3d650cede946dd866aa1bb752323ab",
            "sha256": "sUNwNj4bdfXoKKMROBTwbMY6gBXIW8m5BR7PpVuAang",
            "ext": ".jpg",
            "mime": "image/jpeg",
            "size": 88.22,
            "url": "/uploads/fd3d650cede946dd866aa1bb752323ab.jpg",
            "provider": "local",
            "provider_metadata": null,
            "created_at": "2020-02-07T10:56:55.799Z",
            "updated_at": "2020-02-07T10:56:55.799Z"
        }
    ],
    "actors": [
        {
            "id": 1,
            "Name": "Brad Pitt",
            "Description": "William Bradley Pitt is an American actor and film producer. He has received multiple awards, including two Golden Globe Awards for his acting, and an Academy Award and a Primetime Emmy Award as producer under his production company, Plan B Entertainment.",
            "created_at": "2020-02-07T12:14:29.664Z",
            "updated_at": "2020-02-07T12:14:29.664Z",
            "Thumbnail": [
                {
                    "id": 2,
                    "name": "brad-pitt.jpg",
                    "hash": "64a9739501da43fa96297e77deba9127",
                    "sha256": "QU66_MQhGCofQCxcbtZ8qtjCbZFEwIS8aixAadYYH8I",
                    "ext": ".jpg",
                    "mime": "image/jpeg",
                    "size": 312.9,
                    "url": "/uploads/64a9739501da43fa96297e77deba9127.jpg",
                    "provider": "local",
                    "provider_metadata": null,
                    "created_at": "2020-02-07T12:14:29.744Z",
                    "updated_at": "2020-02-07T12:14:29.744Z"
                }
            ]
        },
        {
            "id": 3,
            "Name": "Shia Labeouf",
            "Description": "Shia Saide LaBeouf is an American actor, performance artist, and filmmaker. He became known among younger audiences as Louis Stevens in the Disney Channel series Even Stevens, a role for which LaBeouf received a Young Artist Award nomination in 2001 and won a Daytime Emmy Award in 2003.",
            "created_at": "2020-02-07T12:33:57.216Z",
            "updated_at": "2020-02-07T12:33:57.216Z",
            "Thumbnail": [
                {
                    "id": 4,
                    "name": "shia-lebeouf.jpeg",
                    "hash": "31bcdc49c8cb4d009506809eab66a146",
                    "sha256": "ooBzoBb0HHao-i8hy9c-UD41CzmAvOniLF10Vaa5Ezo",
                    "ext": ".jpeg",
                    "mime": "image/jpeg",
                    "size": 100.66,
                    "url": "/uploads/31bcdc49c8cb4d009506809eab66a146.jpeg",
                    "provider": "local",
                    "provider_metadata": null,
                    "created_at": "2020-02-07T12:33:57.275Z",
                    "updated_at": "2020-02-07T12:33:57.275Z"
                }
            ]
        }
    ],
    "directors": [
        {
            "id": 2,
            "Name": "David Ayer",
            "Description": "David Ayer is an American film director, producer and screenwriter. He wrote Training Day, co-wrote The Fast and the Furious, and directed Harsh Times, Street Kings, End of Watch, Sabotage, Fury, Suicide Squad and Bright.",
            "created_at": "2020-02-07T12:39:27.058Z",
            "updated_at": "2020-02-07T12:39:27.058Z",
            "Thumbnail": []
        }
    ],
    "genres": [
        {
            "id": 1,
            "Title": "Action",
            "Description": null,
            "created_at": "2020-02-07T12:10:56.599Z",
            "updated_at": "2020-02-07T12:10:56.599Z"
        },
        {
            "id": 5,
            "Title": "War",
            "Description": null,
            "created_at": "2020-02-07T12:11:59.157Z",
            "updated_at": "2020-02-07T12:11:59.157Z"
        }
    ]
}

http://localhost:1337/genres/

http://localhost:1337/genres/1

{
    "id": 1,
    "Title": "Action",
    "Description": null,
    "created_at": "2020-02-07T12:10:56.599Z",
    "updated_at": "2020-02-07T12:10:56.599Z",
    "movies": [
        {
            "id": 1,
            "Title": "Fury",
            "Description": "A grizzled tank commander makes tough decisions as he and his crew fight their way across Germany in April, 1945.",
            "created_at": "2020-02-07T10:56:55.724Z",
            "updated_at": "2020-02-07T10:56:55.724Z",
            "Thumbnail": [
                {
                    "id": 1,
                    "name": "fury.jpg",
                    "hash": "fd3d650cede946dd866aa1bb752323ab",
                    "sha256": "sUNwNj4bdfXoKKMROBTwbMY6gBXIW8m5BR7PpVuAang",
                    "ext": ".jpg",
                    "mime": "image/jpeg",
                    "size": 88.22,
                    "url": "/uploads/fd3d650cede946dd866aa1bb752323ab.jpg",
                    "provider": "local",
                    "provider_metadata": null,
                    "created_at": "2020-02-07T10:56:55.799Z",
                    "updated_at": "2020-02-07T10:56:55.799Z"
                }
            ]
        },
        {
            "id": 2,
            "Title": "Salt",
            "Description": "CIA agent Evelyn Salt's life takes an ugly turn when she is accused of planning the assassination of the Russian president. However, she flees and sets out to prove her innocence.",
            "created_at": "2020-02-07T14:17:52.048Z",
            "updated_at": "2020-02-07T14:17:52.048Z",
            "Thumbnail": [
                {
                    "id": 5,
                    "name": "salt.jpeg",
                    "hash": "a6e0dcd61f724e8481cae53a76f16803",
                    "sha256": "eUSaONZSxatrDROoJJ1Zr1g81YFexNJtMk1Y8w_zRjo",
                    "ext": ".jpeg",
                    "mime": "image/jpeg",
                    "size": 5.88,
                    "url": "/uploads/a6e0dcd61f724e8481cae53a76f16803.jpeg",
                    "provider": "local",
                    "provider_metadata": null,
                    "created_at": "2020-02-07T14:17:52.149Z",
                    "updated_at": "2020-02-07T14:17:52.149Z"
                }
            ]
        }
    ]
}

http://localhost:1337/actors/

[
    {
        "id": 1,
        "Name": "Brad Pitt",
        "Description": "William Bradley Pitt is an American actor and film producer. He has received multiple awards, including two Golden Globe Awards for his acting, and an Academy Award and a Primetime Emmy Award as producer under his production company, Plan B Entertainment.",
        "created_at": "2020-02-07T12:14:29.664Z",
        "updated_at": "2020-02-07T12:14:29.664Z",
        "Thumbnail": [
            {
                "id": 2,
                "name": "brad-pitt.jpg",
                "hash": "64a9739501da43fa96297e77deba9127",
                "sha256": "QU66_MQhGCofQCxcbtZ8qtjCbZFEwIS8aixAadYYH8I",
                "ext": ".jpg",
                "mime": "image/jpeg",
                "size": 312.9,
                "url": "/uploads/64a9739501da43fa96297e77deba9127.jpg",
                "provider": "local",
                "provider_metadata": null,
                "created_at": "2020-02-07T12:14:29.744Z",
                "updated_at": "2020-02-07T12:14:29.744Z"
            }
        ],
        "movies": [
            {
                "id": 1,
                "Title": "Fury",
                "Description": "A grizzled tank commander makes tough decisions as he and his crew fight their way across Germany in April, 1945.",
                "created_at": "2020-02-07T10:56:55.724Z",
                "updated_at": "2020-02-07T10:56:55.724Z",
                "Thumbnail": [
                    {
                        "id": 1,
                        "name": "fury.jpg",
                        "hash": "fd3d650cede946dd866aa1bb752323ab",
                        "sha256": "sUNwNj4bdfXoKKMROBTwbMY6gBXIW8m5BR7PpVuAang",
                        "ext": ".jpg",
                        "mime": "image/jpeg",
                        "size": 88.22,
                        "url": "/uploads/fd3d650cede946dd866aa1bb752323ab.jpg",
                        "provider": "local",
                        "provider_metadata": null,
                        "created_at": "2020-02-07T10:56:55.799Z",
                        "updated_at": "2020-02-07T10:56:55.799Z"
                    }
                ]
            }
        ]
    },
    {
        "id": 2,
        "Name": "Angelina Jolie",
        "Description": "Angelina Jolie is an American actress, filmmaker, and humanitarian. The recipient of such accolades as an Academy Award and three Golden Globe Awards, she has been named Hollywood's highest-paid actress multiple times.",
        "created_at": "2020-02-07T12:29:52.506Z",
        "updated_at": "2020-02-07T12:29:52.506Z",
        "Thumbnail": [
            {
                "id": 3,
                "name": "angelina-jolie.jpg",
                "hash": "4a2244aa027948fb9f4980062219db34",
                "sha256": "ebKbAgauLj0VSPvnTQMBbMUaMa7hO2zg5f1qKK2t5Kg",
                "ext": ".jpg",
                "mime": "image/jpeg",
                "size": 778.6,
                "url": "/uploads/4a2244aa027948fb9f4980062219db34.jpg",
                "provider": "local",
                "provider_metadata": null,
                "created_at": "2020-02-07T12:29:52.579Z",
                "updated_at": "2020-02-07T12:29:52.579Z"
            }
        ],
        "movies": [
            {
                "id": 2,
                "Title": "Salt",
                "Description": "CIA agent Evelyn Salt's life takes an ugly turn when she is accused of planning the assassination of the Russian president. However, she flees and sets out to prove her innocence.",
                "created_at": "2020-02-07T14:17:52.048Z",
                "updated_at": "2020-02-07T14:17:52.048Z",
                "Thumbnail": [
                    {
                        "id": 5,
                        "name": "salt.jpeg",
                        "hash": "a6e0dcd61f724e8481cae53a76f16803",
                        "sha256": "eUSaONZSxatrDROoJJ1Zr1g81YFexNJtMk1Y8w_zRjo",
                        "ext": ".jpeg",
                        "mime": "image/jpeg",
                        "size": 5.88,
                        "url": "/uploads/a6e0dcd61f724e8481cae53a76f16803.jpeg",
                        "provider": "local",
                        "provider_metadata": null,
                        "created_at": "2020-02-07T14:17:52.149Z",
                        "updated_at": "2020-02-07T14:17:52.149Z"
                    }
                ]
            }
        ]
    },
    {
        "id": 3,
        "Name": "Shia Labeouf",
        "Description": "Shia Saide LaBeouf is an American actor, performance artist, and filmmaker. He became known among younger audiences as Louis Stevens in the Disney Channel series Even Stevens, a role for which LaBeouf received a Young Artist Award nomination in 2001 and won a Daytime Emmy Award in 2003.",
        "created_at": "2020-02-07T12:33:57.216Z",
        "updated_at": "2020-02-07T12:33:57.216Z",
        "Thumbnail": [
            {
                "id": 4,
                "name": "shia-lebeouf.jpeg",
                "hash": "31bcdc49c8cb4d009506809eab66a146",
                "sha256": "ooBzoBb0HHao-i8hy9c-UD41CzmAvOniLF10Vaa5Ezo",
                "ext": ".jpeg",
                "mime": "image/jpeg",
                "size": 100.66,
                "url": "/uploads/31bcdc49c8cb4d009506809eab66a146.jpeg",
                "provider": "local",
                "provider_metadata": null,
                "created_at": "2020-02-07T12:33:57.275Z",
                "updated_at": "2020-02-07T12:33:57.275Z"
            }
        ],
        "movies": [
            {
                "id": 1,
                "Title": "Fury",
                "Description": "A grizzled tank commander makes tough decisions as he and his crew fight their way across Germany in April, 1945.",
                "created_at": "2020-02-07T10:56:55.724Z",
                "updated_at": "2020-02-07T10:56:55.724Z",
                "Thumbnail": [
                    {
                        "id": 1,
                        "name": "fury.jpg",
                        "hash": "fd3d650cede946dd866aa1bb752323ab",
                        "sha256": "sUNwNj4bdfXoKKMROBTwbMY6gBXIW8m5BR7PpVuAang",
                        "ext": ".jpg",
                        "mime": "image/jpeg",
                        "size": 88.22,
                        "url": "/uploads/fd3d650cede946dd866aa1bb752323ab.jpg",
                        "provider": "local",
                        "provider_metadata": null,
                        "created_at": "2020-02-07T10:56:55.799Z",
                        "updated_at": "2020-02-07T10:56:55.799Z"
                    }
                ]
            }
        ]
    }
]

http://localhost:1337/actors/1

{
    "id": 1,
    "Name": "Brad Pitt",
    "Description": "William Bradley Pitt is an American actor and film producer. He has received multiple awards, including two Golden Globe Awards for his acting, and an Academy Award and a Primetime Emmy Award as producer under his production company, Plan B Entertainment.",
    "created_at": "2020-02-07T12:14:29.664Z",
    "updated_at": "2020-02-07T12:14:29.664Z",
    "Thumbnail": [
        {
            "id": 2,
            "name": "brad-pitt.jpg",
            "hash": "64a9739501da43fa96297e77deba9127",
            "sha256": "QU66_MQhGCofQCxcbtZ8qtjCbZFEwIS8aixAadYYH8I",
            "ext": ".jpg",
            "mime": "image/jpeg",
            "size": 312.9,
            "url": "/uploads/64a9739501da43fa96297e77deba9127.jpg",
            "provider": "local",
            "provider_metadata": null,
            "created_at": "2020-02-07T12:14:29.744Z",
            "updated_at": "2020-02-07T12:14:29.744Z"
        }
    ],
    "movies": [
        {
            "id": 1,
            "Title": "Fury",
            "Description": "A grizzled tank commander makes tough decisions as he and his crew fight their way across Germany in April, 1945.",
            "created_at": "2020-02-07T10:56:55.724Z",
            "updated_at": "2020-02-07T10:56:55.724Z",
            "Thumbnail": [
                {
                    "id": 1,
                    "name": "fury.jpg",
                    "hash": "fd3d650cede946dd866aa1bb752323ab",
                    "sha256": "sUNwNj4bdfXoKKMROBTwbMY6gBXIW8m5BR7PpVuAang",
                    "ext": ".jpg",
                    "mime": "image/jpeg",
                    "size": 88.22,
                    "url": "/uploads/fd3d650cede946dd866aa1bb752323ab.jpg",
                    "provider": "local",
                    "provider_metadata": null,
                    "created_at": "2020-02-07T10:56:55.799Z",
                    "updated_at": "2020-02-07T10:56:55.799Z"
                }
            ]
        }
    ]
}

http://localhost:1337/directors/

[
    {
        "id": 1,
        "Name": "Phillip Noyce",
        "Description": "Phillip Noyce is an Australian director, producer, and screenwriter of film and television. Since 1977, he has directed over 19 feature films in various genres, including historical drama, thrillers, and action films. He has also directed the Jack Ryan adaptations Patriot Games and Clear and Present Danger and the 2014 adaptation of Lois Lowry's The Giver.",
        "created_at": "2020-02-07T12:37:55.677Z",
        "updated_at": "2020-02-07T12:37:55.677Z",
        "Thumbnail": [],
        "movies": [
            {
                "id": 2,
                "Title": "Salt",
                "Description": "CIA agent Evelyn Salt's life takes an ugly turn when she is accused of planning the assassination of the Russian president. However, she flees and sets out to prove her innocence.",
                "created_at": "2020-02-07T14:17:52.048Z",
                "updated_at": "2020-02-07T14:17:52.048Z",
                "Thumbnail": [
                    {
                        "id": 5,
                        "name": "salt.jpeg",
                        "hash": "a6e0dcd61f724e8481cae53a76f16803",
                        "sha256": "eUSaONZSxatrDROoJJ1Zr1g81YFexNJtMk1Y8w_zRjo",
                        "ext": ".jpeg",
                        "mime": "image/jpeg",
                        "size": 5.88,
                        "url": "/uploads/a6e0dcd61f724e8481cae53a76f16803.jpeg",
                        "provider": "local",
                        "provider_metadata": null,
                        "created_at": "2020-02-07T14:17:52.149Z",
                        "updated_at": "2020-02-07T14:17:52.149Z"
                    }
                ]
            }
        ]
    },
    {
        "id": 2,
        "Name": "David Ayer",
        "Description": "David Ayer is an American film director, producer and screenwriter. He wrote Training Day, co-wrote The Fast and the Furious, and directed Harsh Times, Street Kings, End of Watch, Sabotage, Fury, Suicide Squad and Bright.",
        "created_at": "2020-02-07T12:39:27.058Z",
        "updated_at": "2020-02-07T12:39:27.058Z",
        "Thumbnail": [],
        "movies": [
            {
                "id": 1,
                "Title": "Fury",
                "Description": "A grizzled tank commander makes tough decisions as he and his crew fight their way across Germany in April, 1945.",
                "created_at": "2020-02-07T10:56:55.724Z",
                "updated_at": "2020-02-07T10:56:55.724Z",
                "Thumbnail": [
                    {
                        "id": 1,
                        "name": "fury.jpg",
                        "hash": "fd3d650cede946dd866aa1bb752323ab",
                        "sha256": "sUNwNj4bdfXoKKMROBTwbMY6gBXIW8m5BR7PpVuAang",
                        "ext": ".jpg",
                        "mime": "image/jpeg",
                        "size": 88.22,
                        "url": "/uploads/fd3d650cede946dd866aa1bb752323ab.jpg",
                        "provider": "local",
                        "provider_metadata": null,
                        "created_at": "2020-02-07T10:56:55.799Z",
                        "updated_at": "2020-02-07T10:56:55.799Z"
                    }
                ]
            }
        ]
    }
]

http://localhost:1337/directors/1

{
    "id": 1,
    "Name": "Phillip Noyce",
    "Description": "Phillip Noyce is an Australian director, producer, and screenwriter of film and television. Since 1977, he has directed over 19 feature films in various genres, including historical drama, thrillers, and action films. He has also directed the Jack Ryan adaptations Patriot Games and Clear and Present Danger and the 2014 adaptation of Lois Lowry's The Giver.",
    "created_at": "2020-02-07T12:37:55.677Z",
    "updated_at": "2020-02-07T12:37:55.677Z",
    "Thumbnail": [],
    "movies": [
        {
            "id": 2,
            "Title": "Salt",
            "Description": "CIA agent Evelyn Salt's life takes an ugly turn when she is accused of planning the assassination of the Russian president. However, she flees and sets out to prove her innocence.",
            "created_at": "2020-02-07T14:17:52.048Z",
            "updated_at": "2020-02-07T14:17:52.048Z",
            "Thumbnail": [
                {
                    "id": 5,
                    "name": "salt.jpeg",
                    "hash": "a6e0dcd61f724e8481cae53a76f16803",
                    "sha256": "eUSaONZSxatrDROoJJ1Zr1g81YFexNJtMk1Y8w_zRjo",
                    "ext": ".jpeg",
                    "mime": "image/jpeg",
                    "size": 5.88,
                    "url": "/uploads/a6e0dcd61f724e8481cae53a76f16803.jpeg",
                    "provider": "local",
                    "provider_metadata": null,
                    "created_at": "2020-02-07T14:17:52.149Z",
                    "updated_at": "2020-02-07T14:17:52.149Z"
                }
            ]
        }
    ]
}

As you can see from all the API endpoints that was created by Strapi. They are all nested and include all the many to many relationships. This will be really useful when we want to work with the data from the frontend. Conclusion

We have now created an Movie Database and API that is available for public consumption in around 15 Minutes, form installation to production (locally).

I find that extremely intriguing as I have personally built many APIs before and I can assure you that the development time is not 15 minutes :D

Freddie Freddie 4 years, 10 months ago 0
Login to Comment
No comments have been posted yet, be the first one to comment.
Enable & Write Cron Jobs for Strapi
Enable & Write Cron Jobs for Strapi
A cron job is a useful utility that can be found in any unix-like operating system. It can be used to schedule time-based commands without human intervention. With Strapi, we can use cron jobs to import data or run application tasks automatically. To write cron jobs in Strapi is super...
How to Install Deno on macOS
How to Install Deno on macOS
Deno is a simple, modern and secure runtime for JavaScript and TypeScript, by the creator of Node.js himself, Ryan Dahl. Deno uses the Chrome v8 engine and is built with Rust. The project just reach version 1.0 and got many people in the JavaScript community interested. In this tutori...
Query your Django REST API like a GraphQL API with Django RESTQL
Query your Django REST API like a GraphQL API with Django RESTQL
The hype around GraphQL in recent years has been hard to ignore for any web developer. In short, GraphQL is a query language and runtime for APIs, and it has taken the web with storm. GraphQL makes it possible for front-end developers to query data from a single API endpoint and retri...