API Reference

Complete API documentation for integrating with Zcrypt

Overview

Zcrypt provides a RESTful API for building applications on top of our platform. All API endpoints are serverless functions deployed on Vercel with automatic scaling.

Base URL

https://localhost:3000/api

Authentication

All API requests must include authentication headers with your ZK proof.

POST /api/auth
Content-Type: application/json

{
  "username": "alice",
  "proof": "0x..."
}

Chat API

POST/api/chat

Send an encrypted message to another user

Request Body

{
  "action": "send",
  "sender": "wallet_address",
  "recipient": "wallet_address",
  "content": "plaintext message",
  "encrypted_content": "base64_encrypted",
  "encryption_proof": "zkproof",
  "nonce": "random_nonce",
  "signature": "signature"
}

Response

{
  "success": true,
  "message": {
    "id": 123,
    "created_at": "2025-11-06T..."
  }
}
POST/api/chat

Retrieve messages between two users

Request Body

{
  "action": "getMessages",
  "sender": "wallet_address",
  "recipient": "wallet_address",
  "limit": 50,
  "offset": 0
}

Response

{
  "success": true,
  "messages": [
    {
      "id": 123,
      "sender": "wallet_address",
      "recipient": "wallet_address",
      "encrypted_content": "...",
      "created_at": "2025-11-06T..."
    }
  ],
  "count": 10
}
POST/api/chat

Mark messages as read

Request Body

{
  "action": "markAsRead",
  "recipient": "wallet_address",
  "sender": "wallet_address"
}

Players API

POST/api/players

Get list of online players

Request Body

{
  "action": "getPlayers",
  "walletAddress": "your_wallet"
}

Response

{
  "success": true,
  "players": [
    {
      "address": "wallet_address",
      "username": "alice",
      "online": true,
      "lastSeen": 1699286400000,
      "unreadCount": 0
    }
  ]
}
POST/api/players

Register a new user

Request Body

{
  "action": "register",
  "walletAddress": "wallet_address",
  "username": "alice",
  "publicKey": "public_key"
}

Response

{
  "success": true,
  "user": {
    "address": "wallet_address",
    "username": "alice",
    "online": true
  }
}

Error Handling

All API endpoints return consistent error responses:

{
  "error": "Error message",
  "details": "Additional error details"
}

HTTP Status Codes

200 OK

Request successful

400 Bad Request

Invalid request parameters

401 Unauthorized

Authentication required

500 Internal Error

Server error occurred

Rate Limiting

API requests are rate-limited to ensure fair usage:

  • 100 requests per minute per IP address
  • 1000 requests per hour per authenticated user
  • Rate limit headers included in all responses

Start Building

Ready to integrate Zcrypt into your application? Check out our examples and guides.