Build a weather API that fetches and returns weather data.
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.
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).
Here are some tips to help you get started:
axios
package, if you are using Python, you can use the requests
module.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.
Actively Maintained
We are always improving our content, adding new resources and adding features to enhance your learning experience.
Join the Community
roadmap.sh is the 7th most starred project on GitHub and is visited by hundreds of thousands of developers every month.
Roadmaps Best Practices Guides Videos FAQs YouTube
roadmap.sh by @kamrify @kamrify
Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.
Login to your account
You must be logged in to perform this action.