WEBVTT

00:00.000 --> 00:04.000
Introduction to API's and data fetching.

00:04.000 --> 00:12.000
In this video, we will understand what is API and how data fetching works.

00:12.000 --> 00:15.000
Introduction to API.

00:15.000 --> 00:22.000
An API application programming interface is a way for two computer programs to talk to each other

00:22.000 --> 00:26.000
and share information without needing to understand each other's internal workings.

00:26.000 --> 00:31.000
Each API usually holds specific data or services,

00:31.000 --> 00:38.000
a weather API holds weather data, a maps API holds location data,

00:38.000 --> 00:43.000
and a payments API handles money transactions.

00:43.000 --> 00:49.000
Understanding data, fetching, data fetching, the action of asking for that information

00:49.000 --> 00:51.000
and bringing it into your app.

00:51.000 --> 00:58.000
Example, the weather app fetches data like today's temperature from the weather API

00:58.000 --> 01:01.000
and shows it on your screen.

01:01.000 --> 01:04.000
Let's understand it with the code.

01:04.000 --> 01:10.000
HTML structure, a text box to type the city name, a button to check the weather,

01:10.000 --> 01:13.000
a paragraph to show the result.

01:13.000 --> 01:17.000
Javascript function reads the city name you typed.

01:18.000 --> 01:25.000
Fetch data from API, the fetch function asks the WTTR.N API for weather data of that city.

01:25.000 --> 01:29.000
The API replies in JSON format.

01:29.000 --> 01:34.000
We pick the temperature, temp underscore C from the response.

01:34.000 --> 01:40.000
Show result on screen displays the temperature in the paragraph tag.

01:40.000 --> 01:45.000
Error handling, if something goes wrong, like wrong city name or no internet,

01:45.000 --> 01:48.000
it shows an error message.

01:48.000 --> 01:51.000
Checking the output.

01:51.000 --> 01:52.000
You type a city name.

01:52.000 --> 01:55.000
The app sends a request to the weather API.

01:55.000 --> 02:01.000
The API fetches the data and sends back a response in JSON format.

02:01.000 --> 02:08.000
So now you learned that an API provides the data and data fetching brings that data into your app.

