读取运行结果
curl --request GET \
--url https://api-datahub.bazhuayu.com/v1/runs/{run_id}/recordsimport requests
url = "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {method: 'GET'};
fetch('https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records")
.get()
.build()
val response = client.newCall(request).execute()false{
"run_id": "<string>",
"dataset_id": "<string>",
"records": [
{}
],
"partial": true,
"pagination": {
"offset": 123,
"limit": 123,
"count": 123,
"total": 123,
"has_more": true
}
}运行与结果
读取运行结果
分页读取一次运行产出的记录,支持 JSON、JSONL、CSV 与列裁剪。
GET
/
v1
/
runs
/
{run_id}
/
records
读取运行结果
curl --request GET \
--url https://api-datahub.bazhuayu.com/v1/runs/{run_id}/recordsimport requests
url = "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {method: 'GET'};
fetch('https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);
Console.WriteLine("{0}", response.Content);
val client = OkHttpClient()
val request = Request.Builder()
.url("https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records")
.get()
.build()
val response = client.newCall(request).execute()false{
"run_id": "<string>",
"dataset_id": "<string>",
"records": [
{}
],
"partial": true,
"pagination": {
"offset": 123,
"limit": 123,
"count": 123,
"total": 123,
"has_more": true
}
}端点
GET https://api-datahub.bazhuayu.com/v1/runs/{run_id}/records
Authorization: Bearer <API Key>)。
分页读取运行产出的记录。format 支持 json(默认,带信封与分页)、jsonl、csv;fields 用逗号分隔选择列。
运行进行中也可以读,读到的是截至当前已产出的部分,pagination.total 会持续增长;完整结果要等终态。partial 为 true 表示运行部分成功或被取消,这些记录有效且已计费。
只能读自己发起的运行:别人的与不存在的 run_id 都返回 404。
请求
路径参数
string
必填
运行标识。
查询参数
integer
默认值:"0"
分页起点。范围 ≥ 0。
integer
默认值:"100"
每页条数,最大 10000。范围 1 到 10000。
string
默认值:"json"
输出格式。
json 带信封与分页;jsonl 每行一条;csv 表格。取值:json / jsonl / csv。string
逗号分隔的字段名,只返回这些列,例如
title,price,url。示例请求
curl \
-H "Authorization: Bearer $BAZHUAYU_API_KEY" \
"https://api-datahub.bazhuayu.com/v1/runs/run_c62bc0fb8df2/records?offset=0&limit=100"
响应
200 成功
{
"data": {
"run_id": "run_c62bc0fb8df2",
"dataset_id": "ds_0bd5345d13d0",
"records": [
{
"review_id": "103c9e-0000"
},
{
"review_id": "103c9e-0001"
}
],
"partial": false,
"pagination": {
"offset": 0,
"limit": 2,
"count": 2,
"total": 20,
"has_more": true
}
}
}
format=jsonl 与 format=csv 时响应体是原始文本,不包信封;分页参数仍然有效。
响应包在 data 字段中,其内容如下。
string
运行标识。
string
必填
结果所在的数据集。
object[]
必填
记录数组,每条结构由 App 的
output_schema.record 决定。boolean
运行是否部分成功或被取消。
错误
| HTTP | code | category | 说明 |
|---|---|---|---|
| 401 | unauthorized | forbidden | 缺少或无效的 API Key。 |
| 404 | run-not-found | not_found | 运行不存在,或不是当前账号发起的。 |
{"error": {code, category, message, retryable}},见错误。
客户端库
# 自动翻页遍历全部记录
for record in client.iterate_records("run_c62bc0fb8df2", batch=500):
print(record)
# 单页
page = client.get_records("run_c62bc0fb8df2", offset=0, limit=100, fields="title,price")
# 整份导出为文本(jsonl / csv)
text = client.export_records("run_c62bc0fb8df2", format="csv")
// 自动翻页遍历全部记录
for await (const record of client.iterateRecords("run_c62bc0fb8df2", { batch: 500 })) {
console.log(record);
}
// 单页
const page = await client.getRecords("run_c62bc0fb8df2", { offset: 0, limit: 100, fields: "title,price" });
// 整份导出为文本(jsonl / csv)
const text = await client.exportRecords("run_c62bc0fb8df2", "csv");
