Glossary
Last Updated Jul 18, 2023

API Request

Emma Jagger

Table of Contents:

Get your free
API
key now
4.8 from 1,863 votes
See why the best developers build on Abstract
START FOR FREE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required

What is an API Request?  

In a REST API, a request is issued by a client to a server. A client makes a request to an API at an endpoint which it has access to. The API validates the request and passes the request to the destination server or program. The server sends a response back, first through the API, which then transfers it back to the client. The request is usually packaged in a JSON (JavaScript Object Notation) file. JSON is ubiquitous because it's lightweight and easy to read, but it's not a required format.  

What Can an API Request Do?

A client can issue different kinds of requests, of which there are four main types:

  • GET - This request reads information from a record in the database
  • PUT- This request changes a record’s information in the database
  • POST - This request creates a new record in the database
  • DELETE - This request removes a record from the database.  

An API request isn't always just asking for something, but to perform an action, like adding or modifying data on a server accessed through an API. REST provides an architecture for HTTP clients and servers to understand and process these requests.

What is in an API Request?  

A request might look like this:


fetch('https://jsonplaceholder.typicode.com/todos/1')
  .then(response => response.json())
  .then(json => console.log(json))

This request goes to the URL `https://jsonplaceholder.typicode.com/` at the API endpoint `todos/1`. The server receives these instructions at the endpoint, and returns a JSON with the requested information from the server:


{
	"userId": 1,
	"id": 1,
	"title": "delectus aut autem",
	"completed": false
}

So what is happening here? The client requested ("fetched") information from the API URI at `https://jsonplaceholder.typicode.com/`, specifically the endpoint at `todos/1` by sending  its request to the API. The API authenticates the request and makes a call to the server. The server returns the requested information to the API, and the API sends a JSON card in return with the requested information back to the client.  

API Authentication and Query Parameters

This request doesn't include an authentication key, which is usually issued by the API provider for security purposes. It also has no query parameters, which are attached to the end of a URL and separated from the URL by a question mark (?). For example, in a request to the Currency Exchange Rate API, the currency to convert to and from, as well as the amount, sent from the user to the API would be a query parameter.  

Conclusion

API requests operate within REST architecture, providing a structured way for developers to communicate with remote resources through endpoints. This structure makes REST APIs popular, easy to use, and also secure. APIs[let you open up access to your resources while maintaining security and control.

Get your free
API
key now
4.8 from 1,863 votes
See why the best developers build on Abstract
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required