Authentication
All API requests require authentication using Bearer tokens. You'll need to include your API token in the Authorization header of each request.
Authorization: Bearer your-api-token-here
Obtaining an API Token
To obtain an API token, you need to:
- Register an account on our platform
- Log in to your account
- Navigate to your profile settings
- Generate a new API token
Login
Use this endpoint to obtain an authentication token. Note: This endpoint has rate limiting of 3 attempts every 10 minutes.
POST
/api/login
Request Body
Parameter | Type | Required | Description |
---|---|---|---|
username |
string | Yes | Your username |
password |
string | Yes | Your password |
Example Request
curl -X POST "https://api.dobridobrev.com/api/login" \
-H "Content-Type: application/json" \
-d '{
"username": "your-username",
"password": "your-password"
}'
Response
{
"message": "Login successful",
"data": {
"token": "your-api-token",
"user": {
"user_id": 1,
"username": "johndoe",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"gender": "male",
"birthday": "1990-01-01",
"country_id": 1,
"user_status": "active",
"role_id": 2
}
}
}
Error Responses
Status | Description |
---|---|
401 | Invalid credentials |
429 | Too many login attempts. Please try again in 10 minutes. |
Register
Use this endpoint to create a new user account.
POST
/api/register
Request Body
Parameter | Type | Required | Description |
---|---|---|---|
username | string | Yes | Username (max 64 characters) |
string | Yes | Valid email address | |
password | string | Yes | Password (min 8 characters) |
password_confirmation | string | Yes | Password confirmation |
first_name | string | Yes | First name (max 64 characters) |
last_name | string | Yes | Last name (max 64 characters) |
gender | string | Yes | Gender (male or female) |
birthday | date | Yes | Date of birth |
country_id | integer | No | ID of the user's country |
Example Request
{
"username": "johndoe",
"email": "[email protected]",
"password": "password123",
"password_confirmation": "password123",
"first_name": "John",
"last_name": "Doe",
"gender": "male",
"birthday": "1990-01-01",
"country_id": 1
}
Response
{
"message": "Registration successful",
"data": {
"token": "your-api-token",
"user": {
"user_id": 1,
"username": "johndoe",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"gender": "male",
"birthday": "1990-01-01",
"country_id": 1,
"user_status": "active",
"role_id": 2
}
}
}
Error Responses
Status | Description |
---|---|
422 | Validation Error - Invalid or missing fields |