Skip to content
API Cheat Sheet
Back to Blog
Technology & AI11 min read

API Cheat Sheet

G

GoBizly

10 October 2026

API Cheat Sheet: REST, HTTP Methods, Status Codes & Examples

An API (Application Programming Interface) allows different software applications or components to communicate with each other through a defined set of rules.

APIs power many everyday digital experiences, including online payments, social media integrations, weather applications, e-commerce websites, marketing platforms, and AI tools.

This cheat sheet explains the essential API concepts, terminology, HTTP methods, status codes, authentication mechanisms, and practical examples beginners should understand.

1. What Is an API?

An API defines how one software component can request functionality or data from another component.

For example, a weather application may use a weather service's API to retrieve current temperature information and display it to users.

How an API Works

  1. A client sends a request.

  2. An API receives and processes the request.

  3. The server performs the required operation.

  4. The API returns a response.

  5. The client processes and displays the result.

Example: A website requests product information from an e-commerce API and displays the returned product name, price, and availability.

Common API Use Cases

  • Payment processing.

  • Login and authentication.

  • Weather information.

  • Maps and navigation.

  • Customer relationship management integrations.

  • Marketing analytics and reporting.

  • Social media publishing.

  • AI-powered applications.

  • Data exchange between business systems.

2. Essential API Terminology

Term

Meaning

API

Interface through which software components communicate

Client

Application making a request

Server

System that processes a request or provides a service

Endpoint

Address identifying a particular API resource or operation

Request

Message sent to an API

Response

Message returned by an API

HTTP

Protocol commonly used for web API communication

URL

Address identifying a resource

Header

Metadata accompanying a request or response

Body

Content carried in a request or response

Payload

Data exchanged through a message

Authentication

Process of verifying identity or credentials

Authorization

Process of determining permitted actions

Token

Value used for authentication or authorization

JSON

Common data-interchange format

Rate limit

Restriction on the number of requests allowed

API documentation

Instructions describing API operations and requirements

3. Types of APIs

APIs can be classified by their access model or communication style.

By Access Model

Public APIs: Available to external developers under the provider's access rules.

Private APIs: Intended for internal systems within an organization.

Partner APIs: Available to approved partners through specific agreements or permissions.

Composite APIs: Combine multiple operations or data sources into a single interaction.

These categories describe access and usage patterns rather than completely separate technical protocols.

By Communication Style

API style

Description

REST

Uses resource-oriented web conventions, commonly over HTTP

SOAP

Uses a structured messaging protocol with XML-based envelopes

GraphQL

Allows clients to request specific data fields through a query language

RPC

Invokes operations or procedures remotely

WebSocket API

Supports two-way communication over a persistent connection

The appropriate approach depends on the application, integration requirements, infrastructure, and performance needs.

4. What Is a REST API?

REST stands for Representational State Transfer. It is an architectural style commonly used to design web APIs.

REST APIs often expose resources through URLs and use HTTP methods to perform operations on those resources.

Example resource endpoints:

GET    https://api.example.com/products
GET    https://api.example.com/products/101
POST   https://api.example.com/products
PUT    https://api.example.com/products/101
PATCH  https://api.example.com/products/101
DELETE https://api.example.com/products/101

These are illustrative endpoints, not live services.

Common REST Concepts

  • Resources are identified by URLs.

  • HTTP methods indicate the intended operation.

  • Requests and responses use representations such as JSON.

  • Statelessness means each request contains the information needed to process it, rather than depending on stored client session state for its meaning.

  • Properly designed REST systems follow additional architectural constraints.

Not every API that uses HTTP and JSON necessarily conforms fully to REST.

5. HTTP Methods

HTTP methods indicate what a client intends to do.

Method

Common purpose

Typical use

GET

Retrieve data

Read a product

POST

Submit data or initiate processing

Create an order

PUT

Replace a resource representation

Replace a product record

PATCH

Partially modify a resource

Update a product price

DELETE

Remove a resource

Delete a product

HEAD

Retrieve response headers without the response body

Check resource metadata

OPTIONS

Discover communication options

Inspect supported methods

Actual behavior depends on the API contract.

GET Example

GET /products/101 HTTP/1.1
Host: api.example.com
Accept: application/json

The client requests product 101.

POST Example

POST /products HTTP/1.1
Host: api.example.com
Content-Type: application/json

Example JSON request body:

{
  "name": "Notebook",
  "price": 150
}

The server may create the product and return its identifier.

PUT vs. PATCH

  • PUT generally represents replacing the target resource's state.

  • PATCH represents applying partial modifications.

The exact fields required and update semantics depend on the API's documentation.

6. HTTP Status Codes

Status codes indicate the general result of an HTTP request.

2xx — Success

Code

Meaning

200 OK

Request succeeded

201 Created

A resource was created

202 Accepted

Request accepted for processing, potentially asynchronously

204 No Content

Request succeeded without a response body

3xx — Redirection

Code

Meaning

301 Moved Permanently

Resource has a permanent redirect

302 Found

Temporary redirect

304 Not Modified

Cached representation may still be used

4xx — Client-Side Request Issues

Code

Meaning

400 Bad Request

Request is invalid or malformed

401 Unauthorized

Valid authentication credentials are missing or unacceptable

403 Forbidden

Server refuses the requested operation

404 Not Found

Resource or endpoint was not found

405 Method Not Allowed

HTTP method is not allowed for the resource

409 Conflict

Request conflicts with the current resource state

415 Unsupported Media Type

Request content type is unsupported

422 Unprocessable Content

Request content is understood but cannot be processed as submitted

429 Too Many Requests

Rate limit has been exceeded

A 401 usually concerns authentication, whereas 403 usually indicates that the request is not permitted. Implementations can vary in how they handle certain cases.

5xx — Server-Side Issues

Code

Meaning

500 Internal Server Error

Unexpected server failure

502 Bad Gateway

Gateway received an invalid upstream response

503 Service Unavailable

Service temporarily unavailable

504 Gateway Timeout

Gateway did not receive a timely upstream response

Important: A status code provides a starting point for troubleshooting. Check the response body and API documentation for the specific cause.

7. API Request Structure

An HTTP request can contain a method, URL, headers, and a body.

Example:

POST /orders HTTP/1.1
Host: api.example.com
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN

{
  "product_id": 101,
  "quantity": 2
}

Request Components

  • Method: The intended operation.

  • URL: The destination resource.

  • Headers: Metadata and authentication information.

  • Body: Data being submitted, when applicable.

Some requests, such as many GET requests, do not require a body.

8. API Response Structure

A response typically contains a status code, headers, and possibly a body.

Example JSON response:

{
  "order_id": 5001,
  "status": "confirmed",
  "total": 300
}

A client can parse the response and use the values in its application.

Responses may also contain error information:

{
  "error": {
    "code": "INVALID_QUANTITY",
    "message": "Quantity must be greater than zero."
  }
}

Error formats differ between APIs. Never assume every API uses the same field names or response structure.

9. JSON: A Common API Data Format

JSON stands for JavaScript Object Notation. It is a text-based format for exchanging structured data.

Example:

{
  "name": "Alex",
  "age": 25,
  "active": true,
  "skills": ["Python", "SQL", "APIs"],
  "address": null
}

JSON Data Types

  • String: "Alex"

  • Number: 25

  • Boolean: true or false

  • Array: ["Python", "SQL"]

  • Object: {"name": "Alex"}

  • Null: null

JSON uses double quotes for strings and property names. Unlike Python dictionaries, JSON does not use True, False, or None; it uses true, false, and null.

10. API Authentication and Authorization

APIs often require clients to prove their identity or demonstrate permission to perform an operation.

API Keys

An API key identifies a client or application and may be used for access control or usage tracking.

Bearer Tokens

A bearer token is commonly sent in the Authorization header:

Authorization: Bearer YOUR_ACCESS_TOKEN

Anyone who obtains a valid bearer token may be able to use its permissions, so tokens must be protected.

OAuth 2.0

OAuth 2.0 is an authorization framework that allows applications to obtain limited access to resources.

It is commonly used when applications need permission to access data or perform operations on behalf of a user.

Basic Authentication

Basic authentication sends a username and password in an encoded form. Encoding is not encryption, so it must be protected by HTTPS and used only where appropriate.

Authentication vs. Authorization

Authentication

Authorization

Verifies identity or credentials

Determines permitted actions

Answers “Who or what is making the request?”

Answers “What is this client allowed to do?”

May involve tokens or credentials

May involve scopes, roles, and permissions

Never place API keys, passwords, or access tokens in public source code, public repositories, or URLs unless the provider explicitly requires a safe, documented mechanism.

11. Query Parameters and Path Parameters

Parameters help identify resources or refine a request.

Path Parameter

GET /products/101

Here, 101 identifies the requested product.

Query Parameters

GET /products?category=books&limit=10

The parameters specify a category and a result limit.

Common uses include:

  • Filtering.

  • Sorting.

  • Pagination.

  • Search terms.

  • Date ranges.

  • Selecting particular fields.

Parameter names and accepted values are defined by each API.

12. Headers You Should Know

Header

Purpose

Accept

Indicates response media types the client can accept

Content-Type

Describes the media type of the request or response body

Authorization

Carries authentication credentials or tokens

User-Agent

Identifies the requesting client software

Cache-Control

Communicates caching directives

If-None-Match

Supports conditional requests using an entity tag

Idempotency-Key

Used by some APIs to help prevent duplicate processing

For JSON requests, clients commonly send:

Content-Type: application/json
Accept: application/json

An API may require additional headers or support different formats.

13. Pagination, Filtering, and Sorting

Large API responses are often split into smaller pages.

Pagination

A page-number API might use:

GET /products?page=2&limit=20

Other APIs use offset-based pagination:

GET /products?offset=20&limit=20

Some APIs return a cursor or a next URL for retrieving the next page.

Always follow the provider's documented pagination method. Do not assume page numbers or offsets are supported.

Filtering

GET /orders?status=completed

Sorting

GET /products?sort=price&order=asc

These are examples of possible API conventions, not universal standards.

14. Rate Limits and API Quotas

A rate limit restricts how frequently a client can call an API.

For example, an API might allow a certain number of requests per minute or day.

When an API returns 429 Too Many Requests:

  1. Read the error response.

  2. Check for a Retry-After header.

  3. Wait before retrying.

  4. Use exponential backoff when appropriate.

  5. Cache results if permitted.

  6. Reduce unnecessary requests.

  7. Review the provider's quota and usage policies.

Some APIs also enforce monthly quotas, concurrent-request limits, or account-specific usage restrictions.

15. What Is an API Endpoint?

An endpoint is a specific address used to access an API resource or operation.

Example base URL:

https://api.example.com/v1

Example endpoints:

GET    /products
GET    /products/101
POST   /orders
GET    /orders/5001

The base URL identifies the API service, while the path identifies a resource or operation within it.

An endpoint is not necessarily equivalent to an entire API; one API commonly provides many endpoints.

16. Testing APIs

API testing verifies that requests, responses, validation rules, security, and business logic behave as expected.

Common Testing Tools

  • Postman.

  • Insomnia.

  • curl.

  • Automated test frameworks.

  • Browser developer tools for relevant web requests.

Basic API Testing Checklist

  1. Confirm the correct base URL and endpoint.

  2. Select the documented HTTP method.

  3. Include required headers.

  4. Supply valid authentication credentials.

  5. Send a valid request body when required.

  6. Verify the status code.

  7. Validate response fields and data types.

  8. Test missing and invalid inputs.

  9. Test permission restrictions.

  10. Check pagination and rate-limit behavior.

  11. Review error handling.

  12. Avoid exposing credentials in logs or shared screenshots.

17. Example: Calling an API With Python

The following example uses Python's requests library to call a public test endpoint.

import requests

url = "https://jsonplaceholder.typicode.com/posts/1"

response = requests.get(url, timeout=10)

response.raise_for_status()

data = response.json()

print(data["title"])

Install the library if it is not already available:

python -m pip install requests

What the Code Does

  • requests.get() sends an HTTP GET request.

  • timeout=10 limits how long the client waits for the request.

  • raise_for_status() raises an exception for unsuccessful HTTP status codes.

  • response.json() parses the JSON response.

  • data["title"] retrieves the title field.

This is a public test service, so it is suitable for basic learning. Real APIs may require authentication and have different availability or usage rules.

18. Common API Errors and Troubleshooting

Problem

Possible cause

What to check

400 Bad Request

Invalid parameters or body

Request syntax and validation rules

401 Unauthorized

Missing, expired, or invalid credentials

Token and authentication method

403 Forbidden

Insufficient permissions

Roles, scopes, and account access

404 Not Found

Incorrect endpoint or resource ID

URL, API version, and resource existence

405 Method Not Allowed

Incorrect HTTP method

Endpoint documentation

415 Unsupported Media Type

Incorrect content type

Content-Type header

429 Too Many Requests

Rate limit exceeded

Quotas and retry instructions

500 Internal Server Error

Server-side failure

Error details and provider status

Timeout

Network or server delay

Connectivity, timeout settings, and service health

Invalid JSON

Unexpected or malformed response

Response body and content type

A successful HTTP response does not automatically mean the business operation produced the expected result. Validate the returned data as well.

19. API Security Best Practices

  • Use HTTPS for sensitive communication.

  • Protect API keys and access tokens.

  • Use least-privilege permissions.

  • Validate incoming data.

  • Apply authentication and authorization correctly.

  • Avoid exposing sensitive information in error messages.

  • Implement appropriate rate limits.

  • Use timeouts and controlled retries.

  • Rotate credentials when required.

  • Store secrets in environment variables or a secret-management system.

  • Avoid logging passwords, tokens, or sensitive payloads.

  • Follow the API provider's security requirements.

For operations that create payments, orders, or other important records, understand whether the API supports idempotency before automatically retrying a request after a timeout.

20. API Interview Questions: Quick Revision

What is an API?

An interface that allows software components to communicate through defined rules.

What is a REST API?

An API designed around REST architectural principles, commonly using HTTP methods and resource-oriented URLs.

What is an endpoint?

An address that identifies a resource or operation exposed by an API.

What is the difference between GET and POST?

GET generally retrieves a representation, while POST commonly submits data or initiates processing.

What is JSON?

A text-based format used to exchange structured data.

What is the difference between 401 and 403?

401 concerns authentication; 403 indicates that the requested operation is not permitted.

What is an API token?

A value used to authenticate or authorize requests, depending on the token design.

What is rate limiting?

A mechanism that restricts how frequently a client can make requests.

What is pagination?

A method for retrieving a large result set in smaller portions.

What is an API timeout?

A limit on how long a client waits for an operation or response.

What is an API response code?

An HTTP status code indicating the general outcome of a request.

What is API testing?

The process of verifying an API's behavior, responses, validation, and security.

21. API Quick Reference

Task

Common approach

Retrieve data

GET

Submit data

POST

Replace resource state

PUT

Partially modify a resource

PATCH

Delete a resource

DELETE

Send JSON

Content-Type: application/json

Request JSON

Accept: application/json

Send bearer token

Authorization: Bearer ...

Successful request

200 OK

Created resource

201 Created

Invalid request

400 Bad Request

Authentication problem

401 Unauthorized

Permission denied

403 Forbidden

Missing resource

404 Not Found

Rate limit exceeded

429 Too Many Requests

Server error

500 Internal Server Error

Conclusion

APIs are a fundamental part of modern software and digital services. Understanding endpoints, HTTP methods, status codes, JSON, authentication, pagination, rate limits, and API testing will help you work with integrations more confidently.

Start by testing simple GET requests, examining JSON responses, and learning how request headers and parameters work. Then progress to authenticated APIs, POST requests, automated testing, and secure integration design.

Use this cheat sheet as a quick reference while learning API concepts and preparing for technology interviews.

#APIs#REST API#HTTP Methods#API Integration#Web Development

Related Posts