Get startedGet started for free

Final thoughts

1. Final thoughts

Congratulations, you have completed our introductory course on working with Python APIs. This is just the start of an exciting journey through the world of APIs and integrations. Using the skills you learned in this course, you are now ready to start exploring how you can integrate data from APIs in your workflows and applications!

2. API basics

In this course we learned all about the role APIs play in modern application development as well as how they enable data sharing over a network or the internet. We learned about the three most common types of Web APIs and explored REST APIs in depth. We explored how we can create and structure a URL with path and query parameters to allow us to use APIs more effectively. Then we looked under the hood of the request and response messages a client and a server exchange to communicate. Lastly, we learned about the different types of HTTP verbs we have available in order to read, create, update, and delete resources using an API.

3. APIs with Python

We explored how we can make integrating with APIs easier using the open-source requests package. We learned how to perform GET, POST, PUT, and DELETE requests and how we can pass a Python dictionary with query parameters using the params argument of any HTTP methods to add query parameters to the URL. Later, we looked at what role headers play in request and response messages and how we can use them to do "content negotiation", allowing us to request content from an API in a different format like JSON or XML. Status codes are a crucial part of API response messages as they inform us how the server responded to our API request, if an error occured or if everything went fine. We learned how we can retrieve the status code from the API response object.

4. Advanced topics

Diving deeper, we learned how to authenticate with APIs that contain private, sensitive, or personal data. We also learned the two most common authentication mechanisms: Basic Authentication and API key or token-based authentication. Using headers, we saw how to use both mechanisms using the requests package. We also learned how to send and retrieve data in a more structured format like JSON. This is especially important when working with complex data types, which is often the case. Using the "accept" header, we could retrieve data in a specific format, and using the json function argument, we were also able to send data to the server in the JSON format.

5. Error handling

At the very end, we learned how to properly handle situations where things don't go as expected. We learned of the three different types of errors, Connection errors that occur before reaching the server, 400 errors which are client errors and 500 errors which indicate something has gone wrong on the server. We explored 2 ways to handle these errors: first, looking at the response status code, and second, using the more robust "raise_for_error" function, which causes the requests package to raise an exception when something goes wrong.

6. Congratulations!

Well done! I hope you enjoyed the course and are eager to start building integrations with the many APIs that are available online today. See you soon!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.