Authentication
POST /api/v1/auth/login
Obtain a JWT token for authorized requests.
{
"email": "user@example.com",
"password": "yourPassword"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6..."
}
Headers: Content-Type: application/json
POST /api/v1/auth/register
Create a new user account.
{
"name": "John Doe",
"email": "john@example.com",
"password": "StrongPass123"
}
Response:
{
"id": "a1b2c3d4",
"email": "john@example.com",
"created_at": "2025-09-17T12:34:56Z"
}
Users
GET /api/v1/users
Retrieve a paginated list of users.
Query Parameters:
page
β page number (default: 1)limit
β items per page (default: 20)
Response:
{
"data": [
{"id":"1","name":"Alice","email":"alice@example.com"},
{"id":"2","name":"Bob","email":"bob@example.com"}
],
"meta": {"page":1,"limit":20,"total":45}
}
Headers: Authorization: Bearer <token>
GET /api/v1/users/:id
Retrieve details for a specific user.
Response:
{
"id":"1",
"name":"Alice",
"email":"alice@example.com",
"created_at":"2025-08-01T09:15:00Z"
}
PUT /api/v1/users/:id
Update a user's profile.
{
"name":"Alice Smith",
"email":"alice.smith@example.com"
}
Response: 204 No Content
DELETE /api/v1/users/:id
Remove a user account.
Response: 204 No Content
Posts
GET /api/v1/posts
List public posts with optional filters.
Query Parameters:
tag
β filter by tagauthor_id
β filter by author
Response:
{
"data":[
{"id":"p1","title":"First Post","author_id":"1"},
{"id":"p2","title":"Another Post","author_id":"2"}
]
}
POST /api/v1/posts
Create a new post (authenticated).
{
"title":"My New Post",
"content":"Markdown **content** goes here...",
"tags":["tech","api"]
}
Response:
{
"id":"p123",
"title":"My New Post",
"created_at":"2025-09-17T13:00:00Z"
}
Error Codes
Code | Description |
---|---|
400 | Bad Request β validation failed |
401 | Unauthorized β missing/invalid token |
403 | Forbidden β insufficient permissions |
404 | Not Found β resource does not exist |
500 | Internal Server Error |