Weekly Python Coding Challenge #3

Christopher Franklin
Weekly Python
Published in
2 min readJan 16, 2021
Photo by Igor Rodrigues on Unsplash

The of the week: Create a python application to fetch data from a remote server.

Beginner Project: As a beginner, you should use this project as an opportunity to learn how to fetch data from a remote service. For this challenge, we are going to specifically focus on fetching data from a public API.

You can find a list of available APIs here: https://github.com/public-apis/public-apis

Pick one that looks interesting and write a simple script that can return the data you are interested in. For example, you can create a script that returns the current weather for a given location.

Beginner Stretch Goal: Parse the response and print out status information about the response itself, such as what format is the data, what is the response code, how long did the request take, etc.

Intermediate Project: As a more experienced developer, you are going to write a CLI Tool that can take any API endpoint and return the results. You should also return basic data that is included in the REST request, such as response code, content type, and anything else you can get.

The CLI Tool should accept an endpoint as an argument. As a first step, you can support just the GET requests.

Intermediate Stretch Goal: Add support for other HTTP Methods, like POST, PUT, and DELETE. If you add the methods, you will also need to support passing in body data to the CLI tool.

Advanced Project: For this week's advanced challenge, you should create a full Command-Line HTTP Client, in the same vein as cURL. At a minimum, it needs to support HTTP Methods, Headers, and Request Body. Implement any other features you can if you have the time!

Advanced Stretch Goal: Add HTTPS support! If you want to get fancy, allow a mechanism for manually choosing which SSL protocol to use (i.e. TLS1.2, SSL3, etc.)

Now, get out there and program!

Chris Franklin
Weekly Python

P.S. Remember, if you complete one of the challenges and found it easy, try the next level up!

P.P.S. Looking for more coding challenges? Join the free weekly newsletter here!

--

--