San Diego - Understanding APIs

🏟️ Stop 1: San Diego

Learn How APIs Work Using Real Stadium Data

What is an API?

Simple Definition:

An API (Application Programming Interface) is like a football game. The coach will tell the quarterback what you want (make a request), the coach goes to the playbook (database), and brings back your play (data).

Why Do We Need APIs?

Imagine if every app had to store ALL data itself - weather, sports scores, maps, etc. That would be impossible! Instead, apps use APIs to ask other services for the data they need, exactly when they need it.

How APIs Work: Step by Step

🏈 The Stadium Information Request

1 You want information
Example: "I need to know about Petco Park"
2 You make a request to the API
Example: Send GET request to /api/stadium?name=petco
3 The API finds the data
API looks in the database for Petco Park information
4 API sends back the data
You receive: name, capacity, team, location, etc.

Try It: Your San Diego Sports Venues

These are the sports venues from YOUR personalized itinerary! Click on any venue card below to fetch its data using an API call.

What Did You Just Learn?

1. APIs are messengers - They fetch specific data you request

2. Endpoints are like addresses - Each endpoint gives you different data

3. Responses are structured - Data comes back in an organized format (usually JSON)

4. You only get what you ask for - APIs return exactly the data you request, nothing more

API Keys: Your Access Pass

What is an API Key?

Most real-world APIs require an API key - think of it like a membership card or password that proves you have permission to use the API. When you want to use a popular API (like Google Maps, weather services, or sports data), you typically need to sign up for an account, and the service will give you a unique API key. You include this key with every request you make, usually in the URL or request header. This helps API providers track who's using their service, prevent abuse, and sometimes charge for usage based on how many requests you make. For example, a request might look like: /api/stadium?venue=petco&key=YOUR_API_KEY_HERE. The API keys in this demo are simplified for learning purposes, but in real applications, keeping your API key secure and not sharing it publicly is crucial!

🎯 Key Takeaway: APIs let different programs talk to each other. You ask for data (request), and the API brings it back (response). It's that simple!

🎯 Test Your Knowledge: Interactive Quiz

Question 1 of 4
What does API stand for?
A) Application Programming Internet
B) Application Programming Interface
C) Advanced Programming Interface
D) Automatic Program Integration
Question 2 of 4
Drag the steps to put the API process in the correct order:
Drag items into the correct order (1-4):
API finds the data in database
You want specific information
API sends back the data
You make a request to API
Drop zones (in order):
Step 1: Drop here
Step 2: Drop here
Step 3: Drop here
Step 4: Drop here
Question 3 of 4
If you want to get information about Snapdragon Stadium, what endpoint should you use?
Type the correct API endpoint below:
Hint: Look at the examples above! Remember the venue name for Snapdragon Stadium.
Question 4 of 4
You made an API request and got this response. Click on the field that shows the stadium capacity:
{
  "venue": "Petco Park",
  "team": "San Diego Padres",
  "capacity": 40209,
  "location": "Downtown"
}

🎉 Quiz Complete!

4/4

Perfect score! You're an API expert!