Search⌘ K
AI Features

Calling REST API

Explore how to call REST APIs in Flutter by accessing the TMDB API to fetch popular movie data. Understand how to obtain and use an API key, make HTTP requests with Dart's http package, and prepare the API endpoint for data retrieval, setting a foundation for handling JSON responses.

In this section, you’ll learn how to access TMDB API to fetch popular movies.

What is an API?

API is an acronym for Application Programming Interface. An API lets two applications talk to each other.

The Movie DB contains information about popular movies and TV shows. API is the way to facilitate the app to fetch information from this big movie data storage into our application.

API key

An API key is a unique identifier given to a user, app, or developer to be able to make API requests. It is used to track the number of requests made by the app.

In the code, we’ll be using a variable apiKey to store the API key to access TheMovieDB API.

final apiKey = "YOUR_API_KEY";

First, you’ll need to get an API key for yourself. You need this to be able to ...