All You Need To Know on APIs With Python
A look at how we use Python to communicate with the web via APIs
Talking to the internet with Python, sounds scary, right? Fortunately, the internet has been in good hands for a long time. Our methods for talking to the internet are well established and surprisingly easy.
We’ll skip the small-talk introduction and get straight to it. This article will cover everything we need to communicate over the web effectively — this includes:
- Application Program Interfaces (APIs)
- JavaScript Object Notation (JSON)
- Requests with Python
- Real world use-cases
Application Program Interfaces
An API is like a magic box. We send data — in a specified format. We then get data back — in a specified format.
This magical box is simply a script kept on a server. It acts as a gatekeeper — we tell the gatekeeper that we would like to know, change, or delete something, and the gatekeeper will (hopefully) perform the action we request and let us know how it went.
Fortunately, APIs are generally very well documented and follow the same usage patterns. The vast majority of Web APIs use the representational state transfer (REST) structure — which sounds far more complicated than it is.