How to get data from an API using requests
Land Your First Data Science Job
A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.
In order to get data from an api, you will need to perform an HTTP call against this API.
That is in simple words a way to make your computer communicate with another service.
To do so, we will need to use the requests Python library.
The API of interest
There exist many APIs, some are free, some other are paid.
If you wonder if a service you know has an api, try googling it with the name API at the end, you might end up finding something.
Today we are using Animechan
Because it is an easy to demonstrate, no authentication required api, which gives you a random anime quote.
Perform an HTTP call
Here you are, you can now work with the just you just got back from the api.
Land Your First Data Science Job
A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.
Related Articles
Continue your learning journey with these related topics
Master Data Science in Days, Not Months 🚀
Skip the theoretical rabbit holes. Get practical data science skills delivered in bite-sized lessons – Approach used by real data scientist. Not bookworms. 📚