Start the free course

Building and integrating

What is REST API in Python?

Python can be used to call a REST API or to build one. Calling an API means asking another service for information or an action. Building an API means creating a way for other programs to ask your application for something. REST is a set of principles for designing these exchanges.

Imagine you write a Python program that suggests what to wear. It asks an external weather service for the temperature in Paris. The service returns weather data, and your program uses it to suggest a jacket. You do not need to measure the weather yourself.

Requests is a Python library, a collection of ready-made code, that helps send these requests. FastAPI helps you build your own API instead. Start by using an existing API to understand the conversation between the two programs.

Your Python program can use an external API.
Your Python program can use an external API.Your Python program requests the weather in Paris from an external weather service. The service returns sample data: 18 degrees Celsius. Your program uses it in a clothing suggestion.Your Python programRequests the weather in ParisAPI requestExternal weather serviceReceives the API requestReturns its weather dataAPI responseYour program reads the replyParis: 18 °C (sample data)Uses it to suggest what to wear

Your code uses the provider’s weather data. You do not need to build a weather service yourself.

Further reading

Browse all API questions