Put it into practice
Use a real API key
Time to put what you've learned into practice. In this lesson, you'll get a real API key and use it to fetch live data. No fake APIs, no test data. The real thing.
We'll use NewsAPI, a free service that provides news headlines from around the world. It's the kind of API that powers the "trending news" section you see in many apps.
Step 1: get your API key
- Go to newsapi.org/register and create a free account
- After signing up, you'll see your API key on the dashboard. It looks something like
e8a41c0f3b2d4a5e9f7c1b3d5a7e9f2c - Copy it. You'll paste it below.
The free plan gives you 100 requests per day. More than enough for this exercise.
Step 2: make your first authenticated request
Paste your API key into the input field below and hit "Send request." The request will fetch today's top headlines from the US:
If it worked, you should see a 200 OK with real, current news articles. Each article has a title, description, url, and source. This is live data, straight from NewsAPI's servers.
If you got an error, double-check that you pasted the full key with no extra spaces.
What just happened
Let's recap what you did:
- You signed up for a service (NewsAPI) and received an API key
- You included that key in the request URL as a query parameter (
apiKey=...) - The server checked the key, confirmed it's valid, and sent back the data
This is exactly how API keys work in the real world. Every app that shows news headlines, weather data, stock prices, or maps has done this same process: sign up, get a key, include it in requests.
The only difference with production apps is that the key is stored securely on the server, not typed into an input field. But the mechanism is identical.
Key takeaways
- Getting an API key is usually just "sign up and copy the key from your dashboard"
- The key goes in the request (here, as a query parameter) so the server knows who you are
- This is how real products integrate with external services