REST API
REST API Specification for Aqua-Protocol Version 3 REST APIs are used to interact with the Aqua-Protocol in Client-Server applications. This includes data syncing and exchange operations between different aqua-services. Early versions of this API were prototypes within the PKC-Guardian project.Base URL
Authentication
Requirement: All endpoints except/session (POST) require a Bearer JWT in the Authorization header.
JWT Details: Issued via SIWE-OIDC, tied to the user’s Ethereum wallet address (secp256k1-derived), configurable lifespan (default: 1 hour).
Aqua Tree Endpoints
Get Aqua Tree Latest
Method: GETPath:
/trees/{genesisHash}/latestDescription: Retrieves all latest revision hashes across all branches of the tree starting from the genesis hash.
Query Parameters
includeMetadata(boolean, default: false): Include full revision details.
Response (minimal)
Response (with includeMetadata=true)
Status Codes
200: Success404: Genesis hash not found401: Unauthorized
Get Aqua Tree Branch
Method: GETPath:
/trees/{revisionHash}/branchDescription: Retrieves the branch from the specified hash back to the genesis hash (backward traversal only).
Query Parameters
page(int, optional, default: 1): Pagination page.limit(int, optional, default: 100): Revisions per page.
Response
Status Codes
200: Success404: Branch hash not found401: Unauthorized
Get Aqua Tree Revision
Method: GETPath:
/trees/{revisionHash}Description: Retrieves details of a specific revision.
Response
Status Codes
200: Success404: Revision not found401: Unauthorized
Post New Tree Revision
Method: POSTPath:
/treesDescription: Creates a new revision, validated against aqua-verifier-js-lib verifier.
Request Body (example for signature type)
Response
Validation
Rejects if:previous_verification_hashdoesn’t exist.- Revision type or fields are invalid/malformed (per aqua-verifier-js-lib).
Status Codes
201: Created400: Invalid/malformed revision (with error details if error_mode=verbose)404: Previous hash not found401: Unauthorized
Verification Endpoints
Verify Aqua Tree
Method: POSTPath:
/verifyDescription: Delegates verification to aqua-verifier-js-lib, returns a detailed report.
Request Body
Response
Status Codes
200: Success400: Malformed input401: Unauthorized
File Endpoints
Get File Object
Method: GETPath:
/files/{fileHash}Description: Retrieves the file object associated with the specified file hash. Supports large files via streaming and partial content delivery.
Query Parameters
None required; optional params likedownload (boolean) could be added later for forcing downloads vs. inline display.
Headers
Range(optional): Specifies byte range (e.g.,bytes=0-1048575for first 1MB). Supports partial content retrieval per RFC 7233.
Response
Status:200 OK (full file) or 206 Partial Content (range request)
Headers:
Content-Type: MIME type of the file (e.g.,application/octet-streamif unknown).Content-Length: Size of the returned content in bytes.X-File-Hash: The file’s hash for client-side verification.Accept-Ranges:bytes(indicates range requests are supported).Content-Range(if 206): Byte range delivered (e.g.,bytes 0-1048575/5242880).
Example Response (full file)
Example Response (partial file)
Status Codes
200: Success (full file delivered)206: Partial Content (range request fulfilled)404: File hash not found401: Unauthorized416: Range Not Satisfiable (if requested range is invalid)
Notes
- Scalability: Use HTTP range requests (via Range header) to support partial downloads, enabling clients to resume transfers or fetch chunks of large files.
- Integrity: Return the file’s hash in the response headers (e.g., Content-MD5 or a custom header like X-File-Hash) so clients can verify the file matches the requested hash.
- Efficiency: Stream the file content to handle large sizes without loading everything into memory.
- Clients can verify integrity by comparing the
X-File-Hashwith the requestedfileHash. - Large files are streamed to avoid memory overload; range support enables resumable downloads.
Session Handling
Login
Method: POSTPath:
/sessionDescription: Creates a new session using SIWE-OIDC authentication.
Request Body (SIWE-OIDC)
Response
Status Codes
201: Session created400: Invalid SIWE message/signature
Logout
Method: DELETEPath:
/sessionDescription: Terminates the current session.
Response
204 No Content
Status Codes
204: Success401: Unauthorized
Session Info
Method: GETPath:
/sessionDescription: Retrieves information about the current session.
Response
Status Codes
200: Success401: Unauthorized
Configuration
Configuration (JSON)
Configuration Options
error_mode:"minimal"(HTTP status only) or"verbose"(detailed messages).key_filter:"all","blacklist", or"whitelist"for Ethereum wallet addresses.
Error Handling
Minimal Mode
Verbose Mode
Invalid Revision
Open Todos for the API
- Add support for file deletion
- Add support for revision deletion