Getting to know "API" using The Movie Database (TMBD)

Getting to know "API" using The Movie Database (TMBD)

Working With Postman Application

Understanding APIs as a newbie web developer can be overwhelming at times and rightly so as it is very important when working as a professional web developer. As you advance in learning web development you will come across APIs. Yes, you will, and as hard as you might not want to hear it, you just have to learn it if you are serious about ever becoming a web developer.

So have you ever wondered what is responsible for the connections between computers or between computer programs? Well in a nutshell that is what an API is.

In the course of this article, we will be explaining what an API is and show how to apply an API using The Movie Database (TMDB) API.

What are APIs?

According to AltexSoft:

An API is a set of programming code that enables data transmission between one software product and another. It also contains the terms of this data exchange.

API is short for Application Programming Interface and it is a tool that allows your program to talk with other applications. Call it a messenger that conveys data back n forth if u want, I am sure you relate to what it is now. They are however different types of APIs but for the scope of this article, we will be focusing on Database APIs which enable the communication between an application and a database management system.

How does it work?

Let's actually see how it works as we would learn other keywords we come across. According to kinsta

“For two software applications to communicate over the internet, one application (referred to as the client) sends a request to the other applications’ API endpoints (referred to as the server). Depending on the API’s abilities, the client might request a resource from a database or ask the server to perform some action in its environment and return the results. On receiving the result from the client, the API (or the server) performs the requested operation and sends the result of the operation back to the client in the form of a response. This response can also include any resources that the client requested.

On this guide, we would be making use of The Movie Database (TMDB) API for our little demonstration, then we would be working with Postman application to make sure this actually work. Alright, right now I know what is on your mind is what exactly is TMDB or Postman?

So what is TMDB?

Think of TMDB as a very specialized version of Wikipedia where everything is editable but very specialized around only movie, TV and actor data. According to themoviedb

The Movie Database (TMDB) is a popular, user editable database for movies and TV shows.

As of this writing TMDB currently have 756,446 movies and 130,263 tv shows. TMDB API provides a fast, consistent and reliable way to get third party data, it allows users to make use of their data in their application and is available for everyone to use.

Postman on the other hand is an API platform for building and using APIs. In this application we will be making use of API request, end points, and API request methods. Whenever you want to enable data transmission you will need to make an API request. Remember I mentioned that an API is like a messenger, well you can say an API request is the message. A clear illustration will be the navigating to the favorite music tab on Spotify app. By clicking that tab, Spotify app sends request to the API asking for your favorite music list. There are fifteen API request methods in postman, for the scope of this guide we will practice just three major ones:

  • GET: for getting information from the endpoint
  • POST: making/creating data at that endpoint.
  • DELETE: used to delete the data we made.

According to Steven Curtis:

An API Endpoint is the URL for a server or a service. These APIs operate through responses and requests — that is you make a request and the API Endpoint makes a response.

A simple example of this is this particular website and article. The website is Hashnode, and your Web Browser requests the content. The Endpoint for this particular article is rob26.hashnode.dev/getting-to-know-api-usin.. , and this is obtained by the browser making a GET request and receiving this article in return.

Endpoints using The Movie Database (TMDB) APIs. Okay now, enough talk and more action. For this part, we will need to download a postman application from google or search for the postman website. Create a workspace and then inside it create a collection, for reference purposes we can call the collection ‘The Movie Database API 3’. The base URL is themoviedb.org/3

1. GET: Fight club movie detail

get api.png

2. POST: Movie rating

Post movie rating.png

3. GET: Token

Get token.png

4. GET: Guest session

Get guest session.png

5. DELETE: TV rating

Del tv rating.png

6. GET: Details for blacklist TV

Get fight club movie detail.png

7. DELETE: Movie ratings

delete request.png

8. POST: Session id

post api.png

There are a lot of endpoints from TMDB to lay your hands on, remember to follow the documentations for each endpoint and you are good to go just like that! You are welcome by the way :)