API Docs

Complete API Reference

API Documentation

Welcome to our REST API documentation. Learn how to integrate and use our endpoints effectively.

Base URL

https://api.example.com/v1

Authentication

All API requests require authentication using an API key in the header.

Authorization: Bearer YOUR_API_KEY_HERE
GET

Get Data

Retrieve data from the server. Use GET to fetch resources.

Get All Users

GET /users

Example Request:

fetch('https://api.example.com/v1/users', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
})
.then(response => response.json())
.then(data => console.log(data));

Example Response:

{
  "status": "success",
  "data": [
    {
      "id": 1,
      "name": "John Doe",
      "email": "john@example.com"
    },
    {
      "id": 2,
      "name": "Jane Smith",
      "email": "jane@example.com"
    }
  ]
}

Get User by ID

GET /users/:id

Example Request:

fetch('https://api.example.com/v1/users/1', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
})
.then(response => response.json())
.then(data => console.log(data));

Example Response:

{
  "status": "success",
  "data": {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com",
    "created_at": "2025-01-15"
  }
}
POST

Create Data

Create new resources on the server.

Create New User

POST /users

Request Body:

{
  "name": "Alice Johnson",
  "email": "alice@example.com",
  "password": "securepass123"
}

Example Request:

fetch('https://api.example.com/v1/users', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Alice Johnson',
    email: 'alice@example.com',
    password: 'securepass123'
  })
})
.then(response => response.json())
.then(data => console.log(data));

Example Response:

{
  "status": "success",
  "message": "User created successfully",
  "data": {
    "id": 3,
    "name": "Alice Johnson",
    "email": "alice@example.com",
    "created_at": "2025-11-02"
  }
}
PUT

Update Data

Update existing resources completely.

Update User by ID

PUT /users/:id

Request Body:

{
  "name": "Alice Smith",
  "email": "alice.smith@example.com",
  "password": "newpassword456"
}

Example Request:

fetch('https://api.example.com/v1/users/3', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Alice Smith',
    email: 'alice.smith@example.com',
    password: 'newpassword456'
  })
})
.then(response => response.json())
.then(data => console.log(data));

Example Response:

{
  "status": "success",
  "message": "User updated successfully",
  "data": {
    "id": 3,
    "name": "Alice Smith",
    "email": "alice.smith@example.com",
    "updated_at": "2025-11-02"
  }
}
DELETE

Delete Data

Remove resources from the server.

Delete User by ID

DELETE /users/:id

Example Request:

fetch('https://api.example.com/v1/users/3', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
})
.then(response => response.json())
.then(data => console.log(data));

Example Response:

{
  "status": "success",
  "message": "User deleted successfully"
}

HTTP Status Codes

100 Continue

Request received, continue process

101 Switching Protocols

Protocol switching requested by client

200 OK

Request successful

201 Created

Resource created successfully

202 Accepted

Request accepted but processing not complete

204 No Content

Request successful, no content returned

301 Moved Permanently

Resource permanently moved to new URL

302 Found

Resource temporarily moved to new URL

304 Not Modified

Cached version still valid, no update needed

400 Bad Request

Invalid request format

401 Unauthorized

Authentication required

403 Forbidden

You do not have permission to access this resource

404 Not Found

Resource not found

408 Request Timeout

Server timed out waiting for the request

429 Too Many Requests

Rate limit exceeded

500 Internal Server Error

Server encountered an unexpected condition

501 Not Implemented

Server does not support the request method

502 Bad Gateway

Invalid response from upstream server

503 Service Unavailable

Server is temporarily unavailable

504 Gateway Timeout

Gateway or proxy timed out