KPOP

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpRequest request = HttpRequest.newBuilder()
		.uri(URI.create("https://k-pop.p.rapidapi.com/idols?q=Jungkook&by=Stage%20Name"))
		.header("X-RapidAPI-Key", "df17610e35msh51d75ac58fb44f9p14c5f0jsn7d95a150e08b")
		.header("X-RapidAPI-Host", "k-pop.p.rapidapi.com")
		.method("GET", HttpRequest.BodyPublishers.noBody())
		.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
{"status":"success","message":"Data fetched successfully","data":[{"Profile":"https://dbkpop.com/idol/jungkook-bts/","Stage Name":"Jungkook","Full Name":"Jeon Jungkook","Korean Name":"전정국","K. Stage Name":"정국","Date of Birth":"1997-09-01","Group":"BTS","Country":"South Korea","Second Country":null,"Height":"178","Weight":"66","Birthplace":"Busan","Other Group":null,"Former Group":null,"Gender":"M","Position":null,"Instagram":null,"Twitter":null}],"count":1}

Cars

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpRequest request = HttpRequest.newBuilder()
		.uri(URI.create("https://car-api2.p.rapidapi.com/api/models?sort=id&direction=asc"))
		.header("X-RapidAPI-Key", "df17610e35msh51d75ac58fb44f9p14c5f0jsn7d95a150e08b")
		.header("X-RapidAPI-Host", "car-api2.p.rapidapi.com")
		.method("GET", HttpRequest.BodyPublishers.noBody())
		.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
{"collection":{"url":"\/api\/models?sort=id\u0026direction=asc","count":20,"total":1158,"pages":58,"next":"\/api\/models?page=2\u0026amp;sort=id\u0026amp;direction=asc","prev":"","first":"\/api\/models?sort=id\u0026direction=asc","last":"\/api\/models?page=58\u0026amp;sort=id\u0026amp;direction=asc"},"data":[{"id":1,"make_id":1,"name":"******* (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":2,"make_id":1,"name":"*** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":3,"make_id":2,"name":"** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":4,"make_id":2,"name":"****** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":5,"make_id":2,"name":"******** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":6,"make_id":2,"name":"** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":7,"make_id":2,"name":"** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":8,"make_id":2,"name":"** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":9,"make_id":3,"name":"******** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":10,"make_id":3,"name":"******** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":11,"make_id":3,"name":"******************* (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":12,"make_id":3,"name":"******** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":13,"make_id":3,"name":"******************* (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":14,"make_id":3,"name":"******************** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":15,"make_id":3,"name":"** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":16,"make_id":3,"name":"** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":17,"make_id":4,"name":"******* (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":18,"make_id":4,"name":"********* (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":19,"make_id":4,"name":"******** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."},{"id":20,"make_id":5,"name":"*** (hidden)","__message":"NOTE: Data is limited to `2020` for non-paying users. Search for 2020 vehicles or subscribe to unlock this data."}]}

Purpose of API

An API allows for a website to make use of the data already out there on the internet. This can enrich a website without having to put together all of the data from scratch.

Backend Implementation

To be able to smoothly integrate an API with a nice frontend display of data, a backend is needed to interpret the JSON.

Additionally, many APIs, especially on sources like RAPIDAPI, limit the number of calls. A backend allows for a workaround of this, so data can be stored and refreshed once per day (instead of once per page load).