Practice: APIs

💡 This is your chance to put what you’ve learned into action.

Try solving these practice challenges to check that you understand the concepts.

Submission

To log your practice for credit:

Submit on Gradescope

  • Practice exercises will be graded for completion not correctness. You have to document that you did the work, but we won't be checking if you got it right.
  • You are encouraged to engage with all the exercises listed on the practice page.
  • You are expected to submit only the details requested on the Gradescope submission.

Fetching from an API in Node

Pick one of the following APIs, read the documentation and get data from the API using NodeJS and fetch:

  • Giphy API: An API for searching for and retrieving animated GIFs. The API documentation includes information about endpoints, request and response formats, and examples of how to use the API.
  • News API: An API for retrieving news articles from around the world. The API documentation includes information about endpoints, request and response formats, and examples of how to use the API.
  • OpenWeatherMap: A weather API that provides weather data for cities around the world. The API documentation includes example requests and responses, as well as information about the data format and available endpoints.

Writing Documentation: Sample Node App (optional)

This Sample app on Replit is missing documentation.

Based on what's in index.js, write documentation for the methods. Include the path and HTTP verb, any expected parameters, what values to expect in return, as well as a general description of the path.

  • Remember to consider the purpose and audience of the documentation you write.
  • You are encouraged to share your documentation with other students for feedback.

Serving an API: Flask (optional)

Open up your previous Flask number guessing game project. Instead of using HTML templates, write an updated version as an API that communicates using JSON. It won't be easy to play using the browser. Instead, you can write a program that uses the requests package to play the guessing game by JSON API instead.