REST API Basics: Requests, Responses, and Status Codes
A REST-style API exposes resources through HTTP requests. The exact conventions vary by service, so use the API's documentation as the source of truth.
What to do
- Read the API documentation for the endpoint, authentication requirements, accepted parameters, rate limits, and data format before sending a request.
- Understand the common methods: GET retrieves data, POST submits data, PUT or PATCH updates data, and DELETE requests removal; an API may apply its own semantics.
- Inspect the status code and response body. A 2xx response generally indicates success, 4xx points to a request or permission issue, and 5xx indicates a server-side problem.
- Use a harmless documented GET endpoint or a test environment first. Keep API keys in a protected server-side environment rather than browser code.
Checks and limitations
- Never send real customer or confidential data to an endpoint unless you are authorized and understand its privacy and security controls.
- A request can change or delete data; verify method, URL, environment, and payload before using a write operation.