使用 DataTrust API 以编程方式访问数据市场资源
Base URL: http://localhost:3001/api/v1
所有API请求需要在HTTP Header中携带API密钥进行认证:
Authorization: Bearer dt_your_api_key_here
您可以在 控制台 → API密钥 页面创建和管理API密钥。
/api/v1/models
免费
搜索和浏览数据模型列表
| 参数 | 类型 | 说明 |
|---|---|---|
keyword | string | 搜索关键词 |
industry | string | 行业筛选 |
grade | string | 等级筛选 (S/A/B+/B/C/D) |
page | int | 页码,默认1 |
per_page | int | 每页数量,默认20 |
/api/v1/models/:id
付费
获取数据模型的完整数据(字段定义、样例数据等)
{
"success": true,
"data": {
"id": 1,
"name": "用户行为数据模型",
"industry": "互联网",
"fields": [...],
"sample_data": [...],
"grade_v4": "A",
"score_total_v4": 82.5
},
"credits_charged": 3.00,
"balance_remaining": 47.00
}
/api/v1/models/:id/fields
付费
仅获取模型的字段定义
/api/v1/models/:id/sample
付费
仅获取模型的样例数据
/api/v1/datasets
免费
搜索认证数据集(企业数据知识产权)
/api/v1/datasets/:id
付费
获取数据集完整信息,包含V6六维评分、字段定义、存证信息
/api/v1/products | /api/v1/resources
免费
浏览数据产品和数据资源列表
/api/v1/products/:id | /api/v1/resources/:id
付费
获取产品或资源详情
/api/v1/account/balance
查询账户余额和免费额度
{
"success": true,
"data": {
"balance": 50.00,
"free_calls_remaining": 85,
"tier": "free"
}
}
/api/v1/account/usage
查询使用量统计
| 状态码 | 错误代码 | 说明 |
|---|---|---|
| 401 | AUTH_REQUIRED | 未提供API密钥 |
| 401 | INVALID_API_KEY | API密钥无效或已撤销 |
| 402 | INSUFFICIENT_BALANCE | 余额不足,请充值 |
| 404 | NOT_FOUND | 请求的资源不存在 |
| 429 | RATE_LIMITED | 请求频率超限,请稍后重试 |
| 500 | INTERNAL_ERROR | 服务器内部错误 |
所有错误响应格式:
{
"success": false,
"error": "错误信息描述",
"code": "ERROR_CODE"
}
# 查询模型列表(免费)
curl -H "Authorization: Bearer dt_your_key" \
"http://localhost:3001/api/v1/models?keyword=金融&page=1"
# 获取模型详情(付费)
curl -H "Authorization: Bearer dt_your_key" \
"http://localhost:3001/api/v1/models/123"
# 查询余额
curl -H "Authorization: Bearer dt_your_key" \
"http://localhost:3001/api/v1/account/balance"
import requests
API_KEY = "dt_your_api_key_here"
BASE_URL = "http://localhost:3001/api/v1"
headers = {"Authorization": f"Bearer {API_KEY}"}
# 搜索数据模型
resp = requests.get(f"{BASE_URL}/models", headers=headers,
params={"keyword": "金融", "page": 1})
data = resp.json()
print(f"共 {data['data']['total']} 个模型")
# 获取模型详情(会扣费)
resp = requests.get(f"{BASE_URL}/models/123", headers=headers)
result = resp.json()
print(f"扣费: ¥{result['credits_charged']}")
print(f"剩余: ¥{result['balance_remaining']}")
const API_KEY = 'dt_your_api_key_here';
const BASE_URL = 'http://localhost:3001/api/v1';
// 搜索数据模型
const res = await fetch(`${BASE_URL}/models?keyword=金融`, {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
const data = await res.json();
console.log(`共 ${data.data.total} 个模型`);
// 获取模型详情(会扣费)
const detail = await fetch(`${BASE_URL}/models/123`, {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
const result = await detail.json();
console.log(`扣费: ¥${result.credits_charged}`);