REST APIs for Beginners: Requests and Responses

A REST API lets you work with things, like customers, posts or orders, by sending standard web requests to addresses that name those things. You use GET to read, POST to create, PUT or PATCH to update and DELETE to remove. The server replies with a status code and, usually, data in JSON. Once you know that pattern, most modern APIs feel familiar.
REST is a style, not a product. It has no official strict standard, so every service applies it a little differently. The core ideas, though, stay the same from one service to the next.
Resources and addresses
In REST, everything is a resource, and each kind of resource lives at an address. A service might expose its customers at /customers and a single customer at /customers/42. The first address means “the collection of customers.” The second means “the customer with ID 42.”
This is why URLs in REST look like nouns. You rarely see addresses such as /getCustomer. The action comes from the method, not from the address.
Addresses often nest. /customers/42/orders can mean the orders belonging to customer 42. Reading the documentation shows you the exact shape each service uses.
The common methods
Five methods cover almost everything.
- GET fetches data and should never change anything. You can call it repeatedly without harm.
- POST creates a new resource. Calling it twice often creates two.
- PUT replaces a resource with the version you send.
- PATCH changes only the fields you include.
- DELETE removes a resource.
The difference between safe and unsafe methods matters for automation. A GET that runs twice does no damage. A POST that runs twice might create duplicates, so your workflow should check for an existing record first.
Reading status codes
Every response carries a three-digit code. You need to know the ranges more than the specifics.
- 200s mean success. 200 is a normal success, 201 means something was created, and 204 means success with nothing to return.
- 400s mean the request has a problem. 400 is a bad request, 401 means you are not identified, 403 means you are not allowed, 404 means the resource was not found, and 429 means you have made too many requests.
- 500s mean the server had trouble. These are often temporary, and trying again later may work.
Your automation should react differently to each family. Retrying a 500 after a pause is reasonable. Retrying a 400 without changing anything is pointless, since the same mistake will return the same answer.
Sending and receiving data
When you create or change a resource, you send data in the request body, usually as JSON. A request to create a contact might include a name and an email. You also set a header telling the server that the body is JSON.
The response often returns the full resource, including fields the server added, such as an ID and a creation time. Save the ID if you will need to update the record later. Many beginners forget this and then cannot find the thing they just made.
Always read the response, even when you expect success. It confirms what the server actually stored, which may differ from what you sent if some values were adjusted.
Query parameters: filtering and sorting
Addresses can include extra instructions after a question mark. These are query parameters. /orders?status=paid&limit=50 asks for paid orders, fifty at a time.
Services use query parameters for filtering, sorting, searching and choosing which fields to return. Using them well keeps your requests small, which speeds up your automation and helps you stay under usage limits.
Check the documentation for the exact names, since they vary. One service might call the page size limit and another per_page.
Pagination: when there is more than one page
APIs rarely return thousands of records in one response. Instead they split results into pages. A response typically includes the first batch and a way to get the next one, such as a page number or a cursor, a token that marks where you stopped.
If you ignore pagination, your automation will quietly process only the first page and miss everything else. This is among the most common and hardest-to-notice bugs. Loop until the response says there are no more pages, and test with a dataset larger than one page.
A quick walk-through ties these together. Suppose you want a list of paid orders. You send a GET to the orders address with a filter for paid status and a page size. The response arrives with a 200 code, a list of orders and a pointer to the next page. You process the list, follow the pointer, and stop when no pointer remains. That loop is the backbone of countless automations.
Authentication in brief
Most REST APIs require you to prove who you are. The usual approaches are an API key in a header, a token that you obtain by logging in, or OAuth, a flow in which a user grants your program limited access.
Whatever the method, send credentials in headers, not in the address, since addresses often end up in logs. Keep the secrets out of shared files.
Idempotency and safe retries
An operation is idempotent if repeating it gives the same result as doing it once. GET, PUT and DELETE are meant to be idempotent. POST usually is not.
Networks fail, and automations retry. For operations that create things, look for an idempotency key, a unique value you send so the server can recognize a repeat and avoid duplicating the work. Not every service supports it, so otherwise do your own check before retrying.
It also pays to read the error body, not just the code. Many services return a short message explaining what was wrong, such as a missing field or an invalid date. That message usually tells you the fix in one line.
Your next step
Pick a service you use and find its REST documentation. Identify one resource, the address of the collection, and the method to list it. Make that request with a test tool and read the status code and body.
Then try a request with a query parameter to filter the results, and look for how pagination works. Writing down those three observations gives you a repeatable pattern for learning any REST API.