Learn how APIs work step by step
In this step, we build a URL that includes all the parameters the API needs:
First, we build the API URL with the necessary parameters:
Now we send an HTTP GET request to the API endpoint. This is like asking a question and waiting for an answer.
We use JavaScript's fetch() function to make the request asynchronously, which means our code can continue running while waiting for the response.
The JavaScript code for sending the request:
The API server has processed our request and sends back data in JSON format (JavaScript Object Notation).
JSON is a lightweight data format that's easy for both humans and computers to read.
The raw JSON response from the API:
We need to extract the specific information we want from the JSON and format it for display.
This involves navigating the JSON structure, converting data types, and formatting values.
The code for processing the data:
Finally, we present the processed data to the user in a clear, readable format.
We add visual formatting (colors, layout) to make the data easier to understand.
The final result displayed to the user: