Blog / Build with AI /
Building a weather dashboard with AI
A weather dashboard is a classic first project with an API. You ask a service for data, get something structured back, and turn it into a page a person can read. The result is visible, practical, and teaches you the pattern behind a huge number of web tools.
This post walks through how I’d build one with an AI chatbot’s help. The finished thing is a page where you type a city and see the current temperature, conditions and a short forecast. It’s a method and an example, not a claim that I’ve published this dashboard.
What you’re really learning
Not weather. You’re learning how to:
- Send a request to an API
- Read the JSON that comes back
- Handle failure (wrong city, no internet, rate limit)
- Show data clearly
That pattern appears in almost every web tool you’ll want to build later.
Step 1: choose a data source
Pick a weather API with a free tier and clear documentation. Several exist, with different limits and terms. Rather than asking a chatbot which one is best, read the provider’s current pricing and usage terms yourself. Pay attention to:
- How many requests you can make per day or minute
- Whether the free tier allows use on a public website
- Whether it needs an API key
- Whether it requires you to credit the source
Some services need no key; others do. Whatever you choose, read the docs page for the “current weather” endpoint and keep it open.
Step 2: the API key problem
If your API needs a key and you put it in the JavaScript on your page, anyone can view it and copy it. For a private page on your own computer, that’s fine. For a public page, a stranger could use your key and burn through your limit, or run up charges.
For a learning project, use a free key, keep the page private, and don’t publish it. If you later publish it, route requests through a small server-side script that holds the key. The rule is the same one I’d apply anywhere: keys belong on a server.
Step 3: ask for a minimal version
I’m a beginner. Write a single HTML file with CSS and JavaScript inside it. There’s a text box for a city name and a Get weather button. On click, fetch the current weather from this API endpoint [paste the documented URL pattern from the docs], and show the city name, temperature, a short description and the date. If the request fails or the city isn’t found, show a friendly message. Don’t use any libraries. Comment the code.
Paste the real endpoint format from the docs. Don’t let the chatbot guess it, as it may invent parameter names or use an old version of the API.
Step 4: read the JSON
Open the browser’s developer tools and look at the network response. You’ll see a structured block of data with names like temperature, humidity and wind. Compare it with what the chatbot’s code reads. If the code asks for a field that doesn’t exist, you’ll see undefined on the page.
This is the single most useful debugging step with APIs: look at the real response, not the AI’s idea of it.
Step 5: handle the awkward cases
- City not found. What does the API return? Does your page show a message or a blank?
- No internet. Turn off Wi-Fi and press the button. A good page says something helpful.
- Slow responses. Show “Loading…” so people know something is happening.
- Units. Celsius or Fahrenheit? Check which the API returns by default and label it.
- Empty input. Don’t call the API with a blank box.
- Rate limits. If you press the button fast ten times, does the API start refusing? Add a short delay between requests.
Step 6: add a forecast
Next prompt: “Using the forecast endpoint documented here, show the next five days as small cards with a date, high and low.” Again, give it the docs. Times can be tricky: a forecast timestamp may be in UTC, and showing it unchanged could put the wrong day on a card for someone far from that time zone. Ask the chatbot how it handles time zones and test with a city far from you.
Step 7: make it kind to your users
- Save the last city in the browser, so the page opens ready.
- Keep it readable on a small screen.
- Don’t auto-refresh every few seconds; that wastes requests.
- Say where the data comes from, as the provider’s terms may require.
What to watch for
- Treat it as information, not a safety tool. Don’t rely on a homemade page for decisions where weather is dangerous. Use official warnings.
- APIs change. Endpoints get retired and formats change. If your dashboard suddenly stops working, check the provider’s notices.
- Don’t scrape. If a site doesn’t offer an API, don’t take its pages without permission.
Why this matters for web work
If you manage sites, you will connect them to outside services: stock feeds, shipping rates, social counters, payment checks. The weather dashboard is a safe rehearsal for all of that. And the habits it builds are the right ones: read the docs, look at the real response, plan for failure and protect the key.
If you’ve done a smaller project first, building a tiny tool with AI is a gentler start.
Key takeaways
- An API project teaches request, response, error handling and display.
- Paste real documentation into the prompt.
- Look at the actual JSON.
- Keys stay off public pages.
Related reading
Which city would you test it with first, and what’s the first thing you’d want it to show?