Skip to main content

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: GET
Path: /trees/{genesisHash}/latest
Description: 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: Success
  • 404: Genesis hash not found
  • 401: Unauthorized

Get Aqua Tree Branch

Method: GET
Path: /trees/{revisionHash}/branch
Description: 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

Pagination omitted if not used (no page or limit provided).

Status Codes

  • 200: Success
  • 404: Branch hash not found
  • 401: Unauthorized

Get Aqua Tree Revision

Method: GET
Path: /trees/{revisionHash}
Description: Retrieves details of a specific revision.

Response

Status Codes

  • 200: Success
  • 404: Revision not found
  • 401: Unauthorized

Post New Tree Revision

Method: POST
Path: /trees
Description: Creates a new revision, validated against aqua-verifier-js-lib verifier.

Request Body (example for signature type)

Response

Validation

Rejects if:
  • previous_verification_hash doesn’t exist.
  • Revision type or fields are invalid/malformed (per aqua-verifier-js-lib).

Status Codes

  • 201: Created
  • 400: Invalid/malformed revision (with error details if error_mode=verbose)
  • 404: Previous hash not found
  • 401: Unauthorized

Verification Endpoints

Verify Aqua Tree

Method: POST
Path: /verify
Description: Delegates verification to aqua-verifier-js-lib, returns a detailed report.

Request Body

Response

Status Codes

  • 200: Success
  • 400: Malformed input
  • 401: Unauthorized

Session Handling

Login

Method: POST
Path: /session
Description: Creates a new session using SIWE-OIDC authentication.

Request Body (SIWE-OIDC)

Response

Status Codes

  • 201: Session created
  • 400: Invalid SIWE message/signature

Logout

Method: DELETE
Path: /session
Description: Terminates the current session.

Response

204 No Content

Status Codes

  • 204: Success
  • 401: Unauthorized

Session Info

Method: GET
Path: /session
Description: Retrieves information about the current session.

Response

Status Codes

  • 200: Success
  • 401: Unauthorized

File Endpoints

Get File Object

Method: GET
Path: /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 like download (boolean) could be added later for forcing downloads vs. inline display.

Headers

  • Range (optional): Specifies byte range (e.g., bytes=0-1048575 for 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-stream if 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).
Body: The file content, streamed as a binary response.

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 found
  • 401: Unauthorized
  • 416: 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-Hash with the requested fileHash.
  • Large files are streamed to avoid memory overload; range support enables resumable downloads.

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