API Playground#
Test the ChatAPI endpoints interactively using Swagger UI. This playground allows you to explore the REST API, view request/response formats, and test endpoints with your own data.
Authentication Required: Remember to set your X-API-Key and X-User-Id headers for authenticated requests.
Interactive API Documentation#
Quick Start Guide#
1. Set Authentication#
Enter your API key and user ID in the authentication section above. These will be automatically included in all API requests.
2. Explore Endpoints#
Browse through the different API endpoints in the Swagger UI. Each endpoint includes:
- Parameters: Required and optional parameters
- Request Body: Expected JSON structure
- Responses: Success and error response formats
- Try it out: Interactive testing
3. Test Endpoints#
Click the “Try it out” button on any endpoint to:
- Modify request parameters
- Execute the request
- View the response
- See request/response headers
Common Test Scenarios#
Create a Room#
- Go to
POST /rooms - Set request body:
{ "type": "dm", "members": ["alice", "bob"] } - Click “Execute”
Send a Message#
- Go to
POST /rooms/{room_id}/messages - Replace
{room_id}with actual room ID - Set request body:
{ "content": "Hello from the API playground!" } - Click “Execute”
Check Health#
- Go to
GET /health - Click “Execute” (no authentication required)
Troubleshooting#
Authentication Errors#
- Ensure your API key is valid and has the correct format
- Check that the user ID corresponds to an existing user
- Verify headers are being sent (check browser network tab)
CORS Issues#
- The playground works best when testing against a local ChatAPI instance
- For production APIs, ensure CORS is properly configured
Rate Limiting#
- Monitor the response headers for rate limit information
- Wait for the reset period if you hit rate limits
WebSocket Testing#
For WebSocket testing, you’ll need a WebSocket client. Here are some options:
Browser Console#
// Connect to WebSocket
const ws = new WebSocket('ws://localhost:8080/ws?api_key=YOUR_KEY&user_id=YOUR_USER');
// Handle messages
ws.onmessage = (event) => {
console.log('Received:', JSON.parse(event.data));
};
// Send a message
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'send_message',
room_id: 'your-room-id',
content: 'Hello via WebSocket!'
}));
};Online WebSocket Testers#
Next Steps#
- REST API Reference - Complete API documentation
- WebSocket API Reference - Real-time API documentation
- Getting Started - Installation and setup guide