Introduction to APIs

Let’s discuss what APIs are, how they work, and why we use them.

As we know the internet is full of fun and interesting websites. A lot of clever programmers have taken advantage of all this free data to create more fun and interesting websites! There are many companies that provide an API or Application Program Interface that we can use to programmatically interact with their websites. There are lots of websites that even provide a Python-specific API that makes interacting with them even easier.

For those that don’t, we will have to find alternate ways to interact with them. One of the popular generic interfaces is called Representational State Transfer or REST, which utilizes the HTTP protocol. Another popular API is called Simple Object Access Protocol or SOAP. The SOAP protocol isn’t as popular as it used to be, so we will most likely need to learn REST. Feel free to check out SOAP too if you’d like.

This chapter will focusing on Python wrappers of APIs. We will look briefly at how to extract data from Twitter, Reddit and Wikipedia in this chapter.

As mentioned previously, be sure to read each website’s Terms and Conditions. There are usually some limitations to their APIs that we need to keep in mind. So be careful and don’t hit their servers hard with queries or they might revoke your access.

Get hands-on with 1200+ tech skills courses.