curl --request POST \
--url https://api.brightdata.com/costs/export/json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"dimension": "web_apis",
"filters": {},
"from": "2026-04-01",
"to": "2026-05-01"
}
'import requests
url = "https://api.brightdata.com/costs/export/json"
payload = {
"dimension": "web_apis",
"filters": {},
"from": "2026-04-01",
"to": "2026-05-01"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({dimension: 'web_apis', filters: {}, from: '2026-04-01', to: '2026-05-01'})
};
fetch('https://api.brightdata.com/costs/export/json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.brightdata.com/costs/export/json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'dimension' => 'web_apis',
'filters' => [
],
'from' => '2026-04-01',
'to' => '2026-05-01'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.brightdata.com/costs/export/json"
payload := strings.NewReader("{\n \"dimension\": \"web_apis\",\n \"filters\": {},\n \"from\": \"2026-04-01\",\n \"to\": \"2026-05-01\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.brightdata.com/costs/export/json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"dimension\": \"web_apis\",\n \"filters\": {},\n \"from\": \"2026-04-01\",\n \"to\": \"2026-05-01\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brightdata.com/costs/export/json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"dimension\": \"web_apis\",\n \"filters\": {},\n \"from\": \"2026-04-01\",\n \"to\": \"2026-05-01\"\n}"
response = http.request(request)
puts response.read_body{
"2026-04-01": {
"gd_l1viktl72bvl7bjuj0": 45.2,
"gd_l1vikfnt1wgvvqz95w": 12.8
},
"2026-04-02": {
"gd_l1viktl72bvl7bjuj0": 38.1
}
}费用明细导出
按维度(products、zones、datasets、Web Scraper API 等)导出账户费用数据,与 Cost Explorer 同源。支持 JSON 或 CSV,按天按资源粒度返回。
curl --request POST \
--url https://api.brightdata.com/costs/export/json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"dimension": "web_apis",
"filters": {},
"from": "2026-04-01",
"to": "2026-05-01"
}
'import requests
url = "https://api.brightdata.com/costs/export/json"
payload = {
"dimension": "web_apis",
"filters": {},
"from": "2026-04-01",
"to": "2026-05-01"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({dimension: 'web_apis', filters: {}, from: '2026-04-01', to: '2026-05-01'})
};
fetch('https://api.brightdata.com/costs/export/json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.brightdata.com/costs/export/json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'dimension' => 'web_apis',
'filters' => [
],
'from' => '2026-04-01',
'to' => '2026-05-01'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.brightdata.com/costs/export/json"
payload := strings.NewReader("{\n \"dimension\": \"web_apis\",\n \"filters\": {},\n \"from\": \"2026-04-01\",\n \"to\": \"2026-05-01\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.brightdata.com/costs/export/json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"dimension\": \"web_apis\",\n \"filters\": {},\n \"from\": \"2026-04-01\",\n \"to\": \"2026-05-01\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brightdata.com/costs/export/json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"dimension\": \"web_apis\",\n \"filters\": {},\n \"from\": \"2026-04-01\",\n \"to\": \"2026-05-01\"\n}"
response = http.request(request)
puts response.read_body{
"2026-04-01": {
"gd_l1viktl72bvl7bjuj0": 45.2,
"gd_l1vikfnt1wgvvqz95w": 12.8
},
"2026-04-02": {
"gd_l1viktl72bvl7bjuj0": 38.1
}
}to 参数不包含结束日期。 指定的日期不会包含在结果中。要匹配控制面板或发票中显示的某个完整自然月,请将 to 设置为下一个月的第一天。例如,from=2026-04-01&to=2026-05-01 将返回 2026 年 4 月的全部数据。何时使用此端点
当GET /zone/cost 无法满足需要时,请使用此端点。/zone/cost 端点仅作用于单个 zone,因此无法拆分 Web Scraper API 的费用(这些费用以 dataset_id 为键,而非 zone 名称),也无法回答诸如”我上月在数据中心代理和 Unlocker 上一共花了多少?“这类跨产品问题。
此端点通过 dimension 参数按 Cost Explorer 中相同的分组进行费用聚合。
| 维度 | 费用分组方式 |
|---|---|
products | 产品家族(datacenter、residential、ISP、mobile、unlocker、SERP API、Browser API 等) |
types | 网络或计费类型 |
zones | 账户中的各个 zone |
datasets | Dataset Marketplace 数据集购买 |
web_apis | Web Scraper API 的 dataset_id |
collectors | Scraper Studio collectors |
domains | 目标域名 |
ws_api_snaps | Web Scraper API 快照 |
snapshots | Dataset 快照 |
按某个维度复现您的月度发票
要获取 2026 年 4 月按 Web Scraper API dataset 拆分的完整月度费用:curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"dimension": "web_apis",
"filters": {},
"from": "2026-04-01",
"to": "2026-05-01"
}' \
"https://api.brightdata.com/costs/export/json"
{
"2026-04-01": {
"gd_l1viktl72bvl7bjuj0": 45.20,
"gd_l1vikfnt1wgvvqz95w": 12.80
},
"2026-04-02": {
"gd_l1viktl72bvl7bjuj0": 38.10
}
}
POST /costs/export/csv。CSV 会将响应转置为每天一行,每个出现在该日期范围内的资源 ID 对应一列,因此列数会随数据而变化:
Day,gd_l1viktl72bvl7bjuj0,gd_l1vikfnt1wgvvqz95w
2026-04-01,45.20,12.80
2026-04-02,38.10,0
使用 filters 字段
filters 对象使用 Bright Data 内部的计费结构语法,与 Cost Explorer 所用语法相同。从零构造过滤条件需要了解该结构。大多数调用方将 filters 留空({}),仅依靠 dimension 参数对响应进行约束。
下面是一个可用示例,将结果限制为 datacenter 与 Web Unlocker 产品:
{
"props": {
"product": {
"whitelist": ["dc", "unblocker"]
}
}
}
速率限制
- 每分钟 1,000 个请求
- 每小时 5,000 个请求
与原始请求日志对账
此端点返回的值是计费的真实数据来源,与控制面板的 Cost Explorer 与”使用情况概览”匹配,并汇总进入您的发票。如果将这些值与您自行采集的原始请求日志(例如转发到 Logz 或 CloudWatch 的访问日志)进行比较,预计会有几个百分点的差异。原始日志可能记录到一些请求,但这些请求由于异步聚合时延或临时网络问题未被提交到计费数据库。您的发票始终反映此端点返回的值。相关端点
- 区域总费用与带宽。单个 zone 在指定日期范围内的费用与带宽。无法返回 Web Scraper API 或 Scraper Studio 的费用。
- 区域带宽统计。仅带宽,不含费用。
- 所有区域带宽统计。跨区域汇总带宽。
- 获取定价方案。账户当前的定价方案和可用方案,以及各产品价格。
授权
Use your Bright Data API Key as a Bearer token in the Authorization header.
How to authenticate:
- Obtain your API Key from the Bright Data account settings at https://brightdata.com/cp/setting/users
- Include the API Key in the Authorization header of your requests
- Format:
Authorization: Bearer YOUR_API_KEY
Example:
Authorization: Bearer b5648e1096c6442f60a6c4bbbe73f8d2234d3d8324554bd6a7ec8f3f251f07df
Learn how to get your Bright Data API key: https://docs.brightdata.com/api-reference/authentication
请求体
The dimension to group costs by. Same dimension semantics as the Control Panel Cost Explorer.
products, types, zones, datasets, web_apis, collectors, domains, ws_api_snaps, snapshots Inclusive start date in YYYY-MM-DD format. UTC.
Exclusive end date in YYYY-MM-DD format. UTC. The day specified is NOT included in the result. To match a calendar month, set to to the first day of the following month (e.g., from=2026-04-01&to=2026-05-01 returns all of April 2026).
Optional filter object. Uses Bright Data's internal charges-structure notation and requires knowledge of that structure to construct. Contact Bright Data support if you need help building a filter.
Example: { "props": { "product": { "whitelist": ["dc", "unblocker"] } } }
响应
Cost breakdown grouped by day, then by resource ID. The resource ID format depends on the requested dimension (e.g., for dimension=web_apis, resource IDs are dataset IDs like gd_l1viktl72bvl7bjuj0). Amounts are billed USD for the day.
Show child attributes
Show child attributes
此页面对您有帮助吗?