← Level 5 – Inventor

Lesson 1 of 8 ⏱ 20 minutes Free preview

What an API is

Discover how websites talk to each other – and how your website can ask about weather, maps, or AI.

A waiter between two kitchens

Imagine a restaurant. You (your website) want to order food, but you’re not allowed into the kitchen (a foreign service – weather, maps, AI). That’s what the waiter is for – they take your order, carry it to the kitchen, and bring you back the finished dish.

That waiter is called an API (Application Programming Interface). It’s an agreed-upon way for programs to ask each other for data:

  1. Your website sends a request (“What will the weather be like tomorrow in Brno?”).
  2. The API passes it to the service that knows the answer.
  3. The service returns a response in an agreed-upon format.

Show me: JSON – a shared language

Programs reply to each other in JSON format. It looks almost like a JavaScript object, which you already know from Magician:

{
  "mesto": "Brno",
  "teplota": 21,
  "slunecno": true,
  "dny": ["Saturday", "Sunday"]
}

Try it right now – open this address in your browser (it’s a real weather API, free, no registration needed):

https://api.open-meteo.com/v1/forecast?latitude=49.19&longitude=16.61&current_weather=true

You’ll see JSON with the current weather in Brno. No graphics – just pure data. You get to build the graphics around it!

💡

APIs are everywhere. When a mobile app shows you a forecast, a bus schedule, or a map, it almost never has that data itself – it asks through an API. Now you’re learning to do the same thing.

Your turn 💪

  1. Open the address above in your browser and find the current temperature and wind speed in the response.
  2. Try changing the latitude and longitude in the address to your own city’s coordinates (find them on a map service – right-click → “What’s here?”).
  3. Write down 2–3 ideas for your project about what outside data would be useful on your website:
🏫 School website – ideas

Weather for a school trip, a map with the school’s location, a lunch menu from the cafeteria’s API (if it has one), holidays and school breaks.

🙋 Personal website – ideas

Weather in your city, a map of places you’ve been, an AI chatbot that answers questions about you for visitors.

🌍 Travel journal – ideas

A map with pins for your trips, weather at your next destination, currency conversion for your travel budget.

⚽ Club website – ideas

Weather for the weekend match, a map of the field for visiting teams, an AI helper explaining the rules of football.

Check: You can explain what an API is (a waiter between programs) and recognize JSON. You’ve seen a real API response in your browser.

What to take away from this lesson