What Is An API?
Written By Richard
Last updated About 1 month ago
An API (Application Programming Interface) is an interface that allows two applications or systems to communicate and exchange data with each other. Instead of building everything from scratch, APIs let developers access data or functions of one application from another easily and securely.
For example, when you use Sheetfetch to pull data from YouTube, Google Sheets, or another service, you are interacting with that service’s API.
1. URL and Endpoint
A URL (Uniform Resource Locator) is the address used to access the API on the internet. It usually looks like this:
https://api.example.com/v1/usershttps://api.example.com→ base URL: main API address/v1/users→ endpoint: specific access point to get or modify data
An endpoint is where you send a request to receive data. Each endpoint usually serves a specific purpose, such as fetching user lists, creating new users, or deleting data.
2. Request Method (HTTP Methods)
When calling an API, you must specify the request method. Common methods include:
GET: Retrieve data from the server
POST: Create new data on the server
PUT: Update existing data
PATCH: Partially update data
DELETE: Remove data
OPTIONS: Check which methods are supported
Each endpoint may allow one or more methods depending on the action you want to perform.
3. Headers
Headers are additional information sent with a request to help the server process it. Common headers include:
Content-Type: the format of the data being sent (e.g.,application/json)Authorization: authentication info, like a token or API keyAccept: the type of data the client wants to receive
Example:
{
"Content-Type": "application/json",
"Authorization": "Bearer abc123token"
}4. Parameters (Params)
Parameters are values sent with a request to customize the response. There are two main types:
Query Parameters: sent in the URL, usually for filtering, pagination, or search. Example:
GET https://api.example.com/v1/users?limit=10&page=2limit=10→ maximum 10 resultspage=2→ page 2
Body Parameters: data sent in the request body (commonly with POST, PUT, PATCH). Example:
{
"name": "Richard",
"email": "richard@example.com"
}5. Authentication (Auth)
Many APIs require authentication to protect access. Common methods include:
API Key: a unique key to authenticate requests
Bearer Token / OAuth Token: security token sent in the
AuthorizationheaderBasic Auth: username + password encoded in base64
Example header with Bearer Token:
Authorization: Bearer your_token_here6. Full Request Example
GET https://api.example.com/v1/users?limit=5&page=1
Headers:
Content-Type: application/json
Authorization: Bearer abc123tokenExplanation:
Send a GET request to
/v1/usersendpointRetrieve up to 5 users on page 1
Authenticate with a token in the header
Receive data in JSON format
7. Summary
APIs are bridges between applications, enabling standardized data exchange. Key elements to understand when using APIs:
URL / Endpoint: where to send the request
Method: GET, POST, PUT, DELETE, etc.
Headers: additional info, authentication
Parameters: query or body to customize requests
Authentication: ensure the request is authorized
Understanding these elements makes it easy to integrate any service into Sheetfetch or your application.