My Docs

API Documentation

This documentation provides comprehensive information about our RESTful API, including endpoints, parameters, authentication methods, and request/response examples.

Endpoints

GET /api/v1/users

Fetch user information

Request Example

curl -X GET https://api.example.com/api/v1/users
              

Response Example (200)

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

POST /api/v1/auth

Authenticates user credentials

Request Example

curl -X POST https://api.example.com/api/v1/auth \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"secret123"}'

Success Response (200)

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxx",
  "expires_in": 3600
}

Error Response (401)

{
  "error": "Invalid credentials provided"
}

GET /api/v1/posts?author=1

Fetch posts by author ID

Query Parameters

  • author: User ID (required)
  • limit: Max posts to return (default: 10)
  • page: Page number (default: 1)

Parameters

Filtering Parameters

  • status: Filter by post status (draft/published/archived)
  • tag: Filter posts by tag name
  • search: Full-text search across content

Pagination

  • limit: Max results per page (1-100)
  • page: Page number
  • sort: Sort order (date/likes/views)

Authentication

Bearer Token Authentication

All endpoints require a valid JWT token in the Authorization header. Obtain token via POST /api/v1/auth.

curl -H "Authorization: Bearer YOUR_TOKEN_HERE" ...

Code Samples

JavaScript (Fetching User Data)

fetch('https://api.example.com/api/v1/users', {
  headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
})
.then(response => response.json())
.then(data => console.log(data));