Skip to main content

API Reference

info

AquaGen API exposes three blueprints, each serving a distinct audience.

API Blueprints

BlueprintBase PathPurpose
User API/api/userEnd-user mobile/web app
Admin API/api/adminPlatform administration
External API/api/externalThird-party integrations

Swagger UI URLs

EnvironmentUser APIAdmin APIExternal API
Productionhttps://prod-aquagen.azurewebsites.net/api/user/docshttps://prod-aquagen.azurewebsites.net/api/admin/docshttps://prod-aquagen.azurewebsites.net/api/external/docs
Developmenthttp://localhost:5001/api/user/docshttp://localhost:5001/api/admin/docshttp://localhost:5001/api/external/docs

URL Structure

/api/{blueprint}/{resource}[/{action}]
SegmentExamples
Blueprintuser, admin, external
ResourcedeviceData, alerts, industry, accounts
Actionlogin, refresh, offline, granular

Authentication

info

All endpoints (except public login routes) require a JWT token. See Authentication.

Header (recommended):

Authorization: Bearer <token>

Query string (alternative):

?jwt=<token>

Access tokens expire after 4 hours. Refresh tokens expire after 14 days. Use GET /api/user/user/refresh to get a new access token.

note

Every protected route uses current_user['industryId'] (not a request param) as the authoritative industry ID for the authenticated user. Admin routes accept a targetIndustryId header to act on behalf of other industries.


HTTP Methods

MethodUsage
GETRetrieve data — never modifies state
POSTCreate a resource or trigger an action with a body
PUTFull replacement of an existing resource
PATCHPartial update using JSON Patch operations
DELETERemove a resource (soft delete where possible)

Standard Response Envelope

tip

All JSON responses use this envelope — check status and status_code before reading data.

All JSON responses use this envelope:

{
"status": "success",
"status_code": 200,
"message": "Operation completed",
"data": {}
}

On error:

{
"status": "failed",
"status_code": 1403,
"message": "Human-readable error description"
}

Date Format

warning

All request parameters use DD/MM/YYYY. Passing dates in any other format (e.g. YYYY-MM-DD) will result in incorrect query results or a validation error.

All request parameters use DD/MM/YYYY:

startDate=09/11/2024    # November 9, 2024
endDate=30/11/2024 # November 30, 2024

Timestamps in responses use ISO 8601 UTC:

"timestamp": "2024-11-09T10:30:00Z"

Status Codes

CodeNameDescription
200OKRequest succeeded
400Bad RequestMissing/invalid parameters
401UnauthorizedMissing or expired token
403ForbiddenInsufficient permissions
420Invalid TokenJWT expired or user in blocklist
429Too Many RequestsRate limit exceeded
440Session ExpiredToken revoked in token_logs
500Server ErrorUnhandled exception
1401Data Not FoundNo data for query
1403Missing ParameterRequired header or param absent
1430Validation ErrorJSON schema validation failure

Rate Limiting

AquaGen API uses flask-limiter to enforce per-endpoint rate limits. Exceeding the limit returns HTTP 429 with:

{
"message": "Too many requests. Please try again later.",
"status": "failed"
}
note

Default limits: 200 requests/day, 50 requests/hour per IP. Login and OTP endpoints have stricter per-operation limits — see User API Reference.


Input Validation

Query parameters — parsed via Flask-RESTX argument parsers:

requestParser = namespace.parser()
requestParser.add_argument('date1', required=True, type=str, help='DD/MM/YYYY')
requestParser.add_argument('type', choices=['DAY', 'MONTH', 'YEAR'], default='DAY')
requestParser.add_argument('divisionFactor', type=int, default=1000)

Request bodies — validated against JSON schemas in app/validators/schemas/ using jsonschema.validate. Schema validation failures return 1430.

warning

SQL injection — all string parameters pass through @validate_values() from app/security_checks/input_validator.py. A match returns 405. Never bypass this decorator on new endpoints that accept string input.