Ajax-loader-large-white
How to use APIs with Python
A RESTful API

An API, or application programming interface, is kind of like a coding contract: it specifies the ways a program can interact with an application. For example, if you want to write a program that reads and analyzes data from Twitter, you'd need to use the Twitter API, which would specify the process for authentication, important URLs, classes, methods, and so on.

For an API or web service to be RESTful, it must do the following:

  1. Separate the client from the server
  2. Not hold state between requests (meaning that all the information necessary to respond to a request is available in each individual request; no data, or state, is held by the server from request to request)
  3. Use HTTP and HTTP methods (as explained in the next section).

There are some other requirements, but they're beyond the scope of this lesson.

Instructions

Check out the code in the editor. This is a call to the PlaceKitten API. Click Save & Submit Code to see what it does!

?
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

If you get an error saying that the program took too long to run, it's because the kittens didn't respond quickly enough - just try running it again!

script.py
kittens.jpg