API Overview
REST API for PRIV Protocol services including authentication, rate limits, and response formats.
REST API for PRIV Protocol services.
Base URL
https://api.privlabs.io/v1For development and testing:
https://api-dev.privlabs.io/v1Authentication
All requests require an API key or JWT token in the Authorization header.
API Key Authentication
curl -H "Authorization: Bearer pk_live_xxx" \
https://api.privlabs.io/v1/eventsJWT Authentication
For user-specific endpoints, you can use a JWT token obtained from Supabase Auth:
curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
https://api.privlabs.io/v1/user/balanceAPI Key Types
| Prefix | Environment | Use Case |
|---|---|---|
pk_live_ | Production | Live application traffic |
pk_test_ | Development | Testing and development |
Get your API key from the PRIV Dashboard.
Keep your API keys secure. Never expose them in client-side code or public repositories.
Rate Limits
| Plan | Requests/sec | Requests/day |
|---|---|---|
| Free | 10 | 10,000 |
| Pro | 100 | 1,000,000 |
| Enterprise | Custom | Custom |
Rate limit headers are included in all responses:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1704067200Response Format
Success Response
All successful responses follow this structure:
{
"success": true,
"data": { ... }
}Error Response
Error responses include a code and message:
{
"success": false,
"error": {
"code": "INVALID_API_KEY",
"message": "The provided API key is invalid"
}
}Error Codes
| Code | Status | Description |
|---|---|---|
INVALID_API_KEY | 401 | Invalid or missing API key |
UNAUTHORIZED | 401 | User authentication required |
FORBIDDEN | 403 | Insufficient permissions for this resource |
RATE_LIMITED | 429 | Too many requests |
INVALID_REQUEST | 400 | Malformed request body |
VALIDATION_ERROR | 400 | Request validation failed |
NOT_FOUND | 404 | Resource not found |
SERVER_ERROR | 500 | Internal server error |
API Endpoints
Events (SDK Integration)
POST /events- Track events (supports batch)POST /identify- Identify a userPOST /page- Track a page view
Analytics
GET /analytics- Query analytics data with filtering
User Endpoints
GET /user/balance- Get PRIV token balanceGET /user/consent- Get consent preferencesPOST /user/consent- Update consent preferencesGET /user/reputation- Get reputation detailsGET /user/earnings- Get earnings historyPOST /user/earnings/claim- Claim pending earnings
Data Contributions
POST /contributions/upload- Upload a contributionGET /contributions- List user's contributionsGET /contributions/:id- Get contribution detailsDELETE /contributions/:id- Delete a contribution
Wallet Marketplace
GET /marketplace/wallet/listings- Browse listingsPOST /marketplace/wallet/listings- Create a listingGET /marketplace/wallet/listings/:id- Get listing detailsPUT /marketplace/wallet/listings/:id- Update a listingPOST /marketplace/wallet/listings/:id/purchase- Purchase a listingGET /marketplace/wallet/purchases- List purchasesGET /marketplace/wallet/purchases/:id/download- Download purchased data
Labeling Tasks
GET /tasks- Get available tasksPOST /tasks/:id/submit- Submit task answerGET /tasks/history- Get task submission history
Data Marketplace
GET /data/listings- Browse data listingsPOST /data/purchase- Purchase a data listing
Mobile (VPN App)
POST /mobile/session/start- Start VPN sessionPOST /mobile/session/end- End VPN sessionGET /mobile/session/current- Get active sessionGET /mobile/sessions- List session historyGET /mobile/earnings/summary- Get earnings summaryGET /mobile/earnings/history- Get earnings historyPOST /mobile/earnings/claim- Claim mobile earningsPOST /mobile/events- Track mobile eventsPOST /mobile/sync- Sync offline data
Billing (Stripe)
GET /billing/pricing- Get plan pricing (public)POST /billing/create-checkout- Create checkout sessionGET /billing/subscription- Get subscription detailsPOST /billing/portal- Open customer portal
Storage (IPFS)
POST /storage/upload- Upload file (max 10MB)POST /storage/signed-url- Get signed URL for large filesGET /storage/:cid- Get file metadata
Utility
GET /health- API health check
SDKs
Official SDKs handle API communication automatically:
| Language | Package | Status |
|---|---|---|
| JavaScript/TypeScript | @priv/sdk | Available |
| Python | priv-python | Coming soon |
| Go | priv-go | Coming soon |
MCP Server
PRIV also exposes all marketplace operations via an MCP (Model Context Protocol) server. This enables AI agents to interact with the API using the standardized MCP protocol instead of direct REST calls.
| Feature | REST API | MCP Server |
|---|---|---|
| Protocol | HTTP/JSON | JSON-RPC 2.0 (MCP) |
| Discovery | Read docs | Automatic tool discovery |
| Auth | API key header | API key via environment |
| Best for | Web apps, backends | AI agents, LLM tools |
See the MCP Server documentation for details.
CORS
Public SDK endpoints (/events, /analytics, /identify) support CORS with Access-Control-Allow-Origin: *.
Authenticated user endpoints (/user/*, /contributions/*, etc.) require specific origin configuration and support credentials.
Versioning
The API is versioned via the URL path (/v1/). Breaking changes will be introduced in new versions while maintaining backward compatibility in existing versions.