API Documentation
Guide to using our API endpoints
Introduction
This API allows you to interact with our services for managing users, books, and writers. All endpoints require authentication via an API key.
Authentication
Include your API key in the request header:
Authorization: Bearer your_api_key
Obtain your API key from your account dashboard.
Users Endpoints
1. Get Current User (Me)
Retrieve the authenticated user's profile.
GET /api/v1/users/me
Response Example
{ "id": "123", "name": "John Doe", "email": "john@example.com" }
2. List Users
Retrieve a list of all users.
GET /api/v1/users
Response Example
[ { "id": "123", "name": "John Doe", "email": "john@example.com" }, ... ]
3. Update User
Update a user's information.
PUT /api/v1/users/{id}
Request Body
{ "name": "John Doe", "email": "john@example.com" }
Response Example
{ "id": "123", "status": "updated" }
Books Endpoints
1. Create Book
Create a new book.
POST /api/v1/books
Request Body
{ "title": "Book Title", "author_id": "456", "published_year": 2023 }
Response Example
{ "id": "789", "status": "created" }
2. Delete Book
Delete a book by ID.
DELETE /api/v1/books/{id}
Response Example
{ "status": "deleted" }
3. Update Book
Update an existing book.
PUT /api/v1/books/{id}
Request Body
{ "title": "Updated Title", "author_id": "456", "published_year": 2024 }
Response Example
{ "id": "789", "status": "updated" }
4. List Books
Retrieve a list of all books.
GET /api/v1/books
Response Example
[ { "id": "789", "title": "Book Title", "author_id": "456", "published_year": 2023 }, ... ]
Writers Endpoints
1. List Writers
Retrieve a list of all writers.
GET /api/v1/writers
Response Example
[ { "id": "456", "name": "Jane Smith", "bio": "An acclaimed author..." }, ... ]
Error Codes
- 400: Bad Request
- 401: Unauthorized
- 403: Forbidden
- 404: Not Found
- 500: Internal Server Error