Skip to content

Practical JSON · JSON in REST APIs

All tutorials

JSON in REST APIs

REST APIs send and receive JSON. The client sends JSON in the request body (e.g., POST), and the server responds with JSON. Always set Content-Type: application/json.

  • GET returns JSON in the body
  • POST/PUT/PATCH send JSON in the body
  • Content-Type: application/json header
  • Status codes: 200 OK, 201 Created, 400 Bad Request, 404 Not Found
{
  "data": [
    {"id": 1, "title": "First Post"},
    {"id": 2, "title": "Second Post"}
  ],
  "meta": {
    "page": 1,
    "total": 42
  }
}