Chapter 9
Interacting with APIs
IN THIS CHAPTER
Getting and storing API keys
Working with JSON data
Making sense of REST APIs
Checking out a REST API script
Much of the interaction between your Python scripts and internet content will take place through an application programming interface (API). To gain access to an API, you typically have to sign up with the API provider and obtain an API key, which is a unique code provided by an API provider to identify you and your app. Keys are strings of characters and numbers, 20 to 50 characters in length.
In this chapter, I show you how to obtain API keys, store them safely, and use them with Python to take advantage of internet API services. I also show you how to use JSON to format data when interacting with APIs.
Obtaining API Keys
To obtain an API key, you typically need to sign up with the API provider and request access. The steps are usually something like this:
- Go to the website of the API provider, and create a user account or sign into your existing account.
Navigate to the API section of the provider’s website.
It’s often ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access