Files
developer-roadmap/src/data/projects/weather-api-wrapper-service.md
T
Kamran Ahmed ad3f28a8c4 feat: add projects functionality for backend roadmap (#6412)
* Add empty projects listing and cards

* Projects page header

* Projects listing and filtering

* Add project detail page

* Add a task tracker CLI project

* UI changes

* Add projects for expense and task tracker

* Add new projects

* Add blogging platform API project

* Project page UI changes

* Add todo list api project

* Add todo list api project

* Add a project idea for weather service

* Add expense tracker API project

* Add more details to expense tracker

* Add markdown note taking app idea

* Add URL shortener service project

* Add broadcast server project

* Add ecommerce project idea

* Add project on other roadmaps

* Add workout tracker project

* Add image processing project idea

* Add movie reservation system ap

* Add movie reservation system project

* Add realtime leader board system project

* Add details for a database backup utility

* Add project contribution docs

* Fix UI of the discover page
2024-08-07 16:35:19 +01:00

2.7 KiB
Raw Blame History

title, description, isNew, sort, difficulty, nature, skills, seo, roadmapIds
title description isNew sort difficulty nature skills seo roadmapIds
Weather API Build a weather API that fetches and returns weather data. false 7 beginner API
Programming Language
3rd Party APIs
Caching
Environment Variables
title description keywords
Weather API Project Idea Build a weather API that fetches and returns weather data from a 3rd party API.
weather api
backend project idea
backend
nodejs
python
java
golang
spring-boot

In this project, instead of relying on our own weather data, we will build a weather API that fetches and returns weather data from a 3rd party API. This project will help you understand how to work with 3rd party APIs, caching, and environment variables.

Weather API

As for the actual weather API to use, you can use your favorite one, as a suggestion, here is a link to Visual Crossing’s API, it’s completely FREE and easy to use.

Regarding the in-memory cache, a pretty common recommendation is to use Redis, you can read more about it here, and as a recommendation, you could use the city code entered by the user as the key, and save there the result from calling the API.

At the same time, when you “set” the value in the cache, you can also give it an expiration time in seconds (using the EX flag on the SET command). That way the cache (the keys) will automatically clean itself when the data is old enough (for example, giving it a 12-hours expiration time).


Some Tips

Here are some tips to help you get started:

  • Start by creating a simple API that returns a hardcoded weather response. This will help you understand how to structure your API and how to handle requests.
  • Use environment variables to store the API key and the Redis connection string. This way, you can easily change them without having to modify your code.
  • Make sure to handle errors properly. If the 3rd party API is down, or if the city code is invalid, make sure to return the appropriate error message.
  • Use some package or module to make HTTP requests e.g. if you are using Node.js, you can use the axios package, if you are using Python, you can use the requests module.
  • Implement rate limiting to prevent abuse of your API. You can use a package like express-rate-limit if you are using Node.js or flask-limiter if you are using Python.

This project will help you understand how to work with 3rd party APIs, caching, and environment variables. It will also help you understand how to structure your API and how to handle requests.