Introduction
The Masar Eagle API is a RESTful API that provides access to all platform functionality for ride-hailing operations. The API is designed with a microservices architecture and uses a gateway pattern to route requests to the appropriate services.Base URLs
All API requests are routed through the API Gateway:- Identity Service - Authentication and OTP management (
http://identity:8080) - Users Service - User profiles, drivers, passengers, companies (
http://user:8080) - Trips Service - Trip management, bookings, wallets (
http://trip:8080) - Notifications Service - Push notifications and device management (
http://notifications:8080)
API Architecture
The API uses YARP (Yet Another Reverse Proxy) to route requests based on path patterns:Route Pattern Examples
API Versioning
The API currently uses path-based versioning for specific endpoints:- v1:
/api/v1/trips/*- Legacy trip endpoints (maintained for backward compatibility) - Unversioned: Most endpoints use unversioned paths as the current stable version
/api/v2/) when breaking changes are necessary.
Unversioned endpoints represent the current stable API. Versioned endpoints (v1) are maintained for backward compatibility but may be deprecated in future releases.
Request Format
Content Types
The API accepts the following content types:application/json- For most API requestsmultipart/form-data- For file uploads (images, documents)application/x-www-form-urlencoded- For OAuth token requests
Headers
The content type of the request body. Typically
application/json.Bearer token for authenticated requests:
Bearer {access_token}Preferred language for error messages. Supports
ar (Arabic) and en (English). Default: arJSON Serialization
The API uses the following JSON conventions:- Property naming: camelCase (e.g.,
phoneNumber,userId) - Date/Time format: ISO 8601 UTC timestamps (e.g.,
2024-03-10T14:30:00.000Z) - Enums: String values (e.g.,
"admin","driver","passenger") - Case insensitivity: Request property names are case-insensitive
Response Format
Success Responses
Successful responses return the requested data with appropriate HTTP status codes:HTTP Status Codes
The API uses standard HTTP status codes:| Code | Meaning | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource successfully created |
| 204 | No Content | Request succeeded with no response body |
| 400 | Bad Request | Invalid request data or validation error |
| 401 | Unauthorized | Authentication required or invalid token |
| 403 | Forbidden | Insufficient permissions |
| 404 | Not Found | Resource not found |
| 409 | Conflict | Resource conflict (duplicate, etc.) |
| 500 | Internal Server Error | Server error |
| 502 | Bad Gateway | Error connecting to backend service |
| 504 | Gateway Timeout | Request timeout |
File Uploads
File upload endpoints support multipart/form-data with the following limits:Max Request Size
Unlimited (configured via Kestrel)
Supported Formats
Images: JPEG, PNG, WebP, GIF
Upload Example
Cross-Origin Resource Sharing (CORS)
The API supports CORS with the following configuration:- Allowed Origins: All origins (
*) - Allowed Methods: All methods (GET, POST, PUT, PATCH, DELETE, etc.)
- Allowed Headers: All headers
- Credentials: Not supported (use Authorization header instead)
Request/Response Logging
The gateway logs all requests and responses for monitoring and debugging:Logged Information
- Request path, method, and headers (excluding sensitive headers)
- Response status code and headers
- Request/response timestamps and duration
- User ID and trace ID for correlation
Excluded from Logs
- Authorization tokens
- Cookies
- API keys
- Request/response bodies (configurable)
- Health check endpoints (
/health,/metrics,/ready,/live)
Performance Considerations
Response Times
Typical response times: 50-200msTimeouts: 30 seconds (configurable)
Request Limits
No global rate limits currently enforcedService-level limits may apply
OpenAPI/Swagger Documentation
Interactive API documentation is available for each service:- Identity Service:
http://identity:8080/swagger - Users Service:
http://user:8080/swagger - Trips Service:
http://trip:8080/swagger - Notifications Service:
http://notifications:8080/swagger
Swagger endpoints are typically available only in development environments.
Next Steps
Authentication
Learn how to authenticate and obtain access tokens
Error Handling
Understand error responses and how to handle them