Back to Login
API Documentation
Learn how to use the Orient Tanks API for authentication
POST Login Endpoint
POST /api/login/
Authenticate a user with email and password. Returns JWT tokens for API access.
Request Parameters
email
string (required)
password
string (required)
Example Request
curl -X POST http://localhost:8000/api/login/ \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "your_password"
}'
Response Examples
Success Response (200 OK)
{
"user": {
"id": 1,
"email": "user@example.com",
"name": "John Doe",
"role": "plumber",
"phone": "+1234567890"
},
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Error Response (400 Bad Request)
{
"email": ["This field is required."],
"password": ["This field is required."]
}
Authentication Error (401 Unauthorized)
{
"detail": "Invalid email or password."
}
GET Login Endpoint Documentation
GET /api/login/
Get documentation and information about the login endpoint. This is what you see when you visit the login API URL in a browser.
Example Response
{
"message": "Login API Endpoint",
"method": "POST",
"description": "Authenticate user and return JWT tokens",
"required_fields": {
"email": "string - User email address",
"password": "string - User password"
},
"response": {
"user": "User object with profile information",
"refresh": "JWT refresh token",
"access": "JWT access token"
},
"example_request": {
"email": "user@example.com",
"password": "your_password"
}
}
Important Notes
- The login endpoint only accepts POST requests for authentication
- GET requests return documentation information
- Use the returned JWT tokens in the Authorization header for subsequent API calls
- Format:
Authorization: Bearer <access_token> - Refresh tokens can be used to get new access tokens when they expire
Testing Tips
- Use tools like Postman, curl, or your browser's developer tools to test the API
- Make sure to set the Content-Type header to application/json
- For web applications, use the regular login form instead of the API
- The API is designed for mobile apps and third-party integrations