API Reference
DataXchange API
Programmatic access to the PRIV Protocol data marketplace for buying and selling datasets.
Programmatic access to the data marketplace.
List Datasets
GET
/dataxchange/datasetsBrowse available datasets.
Parameters
| Parameter | Type | Description |
|---|---|---|
category | string | Filter by category |
minPrice | string | Minimum price (PRIV) |
maxPrice | string | Maximum price (PRIV) |
sortBy | string | price, dataPoints, created |
order | string | asc or desc |
limit | number | Results per page |
cursor | string | Pagination cursor |
Response
{
"success": true,
"data": {
"datasets": [
{
"id": "ds_abc123",
"title": "DeFi Trading Data - January 2024",
"description": "Swap activity from major DEXs",
"category": "defi",
"price": "100",
"priceUsd": "30.00",
"dataPoints": 50000,
"seller": "0x742d...1234",
"rating": 4.8,
"purchases": 12,
"createdAt": "2024-02-01T00:00:00Z"
}
],
"cursor": "next_cursor",
"hasMore": true
}
}Example
curl "https://api.priv.io/v1/dataxchange/datasets?category=defi&maxPrice=500&limit=20" \
-H "Authorization: Bearer pk_live_xxx"Get Dataset
GET
/dataxchange/datasets/:idGet detailed dataset information.
Response
{
"success": true,
"data": {
"id": "ds_abc123",
"title": "DeFi Trading Data - January 2024",
"description": "Comprehensive swap data from Uniswap, Aave, and more",
"category": "defi",
"price": "100",
"dataPoints": 50000,
"timeRange": {
"start": "2024-01-01",
"end": "2024-01-31"
},
"schema": {
"fields": ["timestamp", "event", "tokens", "amounts", "user_hash"],
"types": ["datetime", "string", "array", "array", "string"]
},
"sample": [
{
"timestamp": "2024-01-15T10:30:00Z",
"event": "swap",
"tokens": ["ETH", "USDC"],
"amounts": ["1-2", "2000-3000"],
"user_hash": "anon_abc123"
}
],
"seller": {
"address": "0x742d...1234",
"rating": 4.8,
"totalSales": 25
}
}
}Purchase Dataset
POST
/dataxchange/purchasePurchase access to a dataset.
Request
{
"datasetId": "ds_abc123",
"signature": "0x..."
}The signature must be generated by signing a message with your wallet.
Response
{
"success": true,
"data": {
"purchaseId": "pur_xyz789",
"accessToken": "at_abc123",
"transactionHash": "0x...",
"downloadUrl": "https://api.priv.io/v1/dataxchange/download/pur_xyz789"
}
}Download
After purchase, download the dataset:
curl "https://api.priv.io/v1/dataxchange/download/pur_xyz789" \
-H "Authorization: Bearer pk_live_xxx" \
-o dataset.jsonMy Purchases
GET
/dataxchange/purchasesList your purchased datasets.
Response
{
"success": true,
"data": {
"purchases": [
{
"id": "pur_xyz789",
"datasetId": "ds_abc123",
"title": "DeFi Trading Data - January 2024",
"price": "100",
"purchasedAt": "2024-02-15T10:00:00Z",
"downloadUrl": "https://api.priv.io/v1/dataxchange/download/pur_xyz789"
}
]
}
}Categories
GET
/dataxchange/categoriesList available categories.
Response
{
"success": true,
"data": {
"categories": [
{
"id": "defi",
"name": "DeFi Trading",
"description": "DEX swaps, lending, staking",
"datasetCount": 150
},
{
"id": "nft",
"name": "NFT Activity",
"description": "Mints, sales, bids",
"datasetCount": 80
}
]
}
}Seller Endpoints
List Dataset
POST
/dataxchange/datasetsCreate a new dataset listing.
{
"title": "My Dataset",
"description": "Description here",
"category": "defi",
"price": "100",
"metadataUri": "ipfs://Qm...",
"signature": "0x..."
}Get Earnings
GET
/dataxchange/earningsView your earnings from dataset sales.
{
"success": true,
"data": {
"total": "500",
"pending": "100",
"withdrawn": "400"
}
}Withdraw
POST
/dataxchange/withdrawWithdraw your earnings.
{
"amount": "100",
"signature": "0x..."
}