0% found this document useful (0 votes)
2 views

How API Works

The document explains how a mobile app can use a Weather API to obtain current weather data without managing it directly. The app sends a request to the Weather API, which processes the request and responds with weather details in JSON format. Finally, the app displays this data in a user-friendly manner.

Uploaded by

hrishighayal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

How API Works

The document explains how a mobile app can use a Weather API to obtain current weather data without managing it directly. The app sends a request to the Weather API, which processes the request and responds with weather details in JSON format. Finally, the app displays this data in a user-friendly manner.

Uploaded by

hrishighayal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Let's take a simple real-world example of an API in action.

Example: Weather API


Imagine you have a mobile app that shows the current weather. Instead of
collecting weather data itself, the app requests data from a weather service like
OpenWeather or WeatherAPI.
How It Works:
1. Your App (Client) Sends a Request
The app sends a request to the Weather API:
bash
CopyEdit
GET https://api.openweathermap.org/data/2.5/weather?
q=Bangkok&appid=YOUR_API_KEY
2. Weather API (Server) Processes the Request
The API fetches the latest weather data for Bangkok.
3. Weather API Responds with Data
The API sends back weather details in JSON format:
json
CopyEdit
{
"city": "Bangkok",
"temperature": "30°C",
"humidity": "80%",
"weather": "Cloudy"
}
4. Your App Displays the Data
The app takes this response and shows it in a user-friendly format.
This way, your app gets weather data without storing or managing it—thanks to
the API!

You might also like