cURL
curl --request GET \
--url https://api.brightdata.com/billing/autorecharge \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.brightdata.com/billing/autorecharge"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.brightdata.com/billing/autorecharge', 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/billing/autorecharge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.brightdata.com/billing/autorecharge"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.brightdata.com/billing/autorecharge")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brightdata.com/billing/autorecharge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"regular": {
"available": true,
"enabled": true,
"pmethod_id": "<string>",
"amount": 123,
"threshold": 123,
"limits": {
"min_amount": 123,
"max_amount": 123
}
},
"dataset": {
"available": true,
"enabled": true,
"pmethod_id": "<string>"
},
"suspended": true
}User authentication is requiredYour API key lacks the required permissions for this action. You can change your token permissions at https://brightdata.com/cp/setting/users<string>账户与状态
获取自动充值设置
使用 Bright Data 账号管理 API 的 GET /billing/autorecharge 读取账户的常规自动充值和数据集自动充值设置,包括充值金额、触发阈值和金额限制。
GET
/
billing
/
autorecharge
cURL
curl --request GET \
--url https://api.brightdata.com/billing/autorecharge \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.brightdata.com/billing/autorecharge"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.brightdata.com/billing/autorecharge', 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/billing/autorecharge",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.brightdata.com/billing/autorecharge"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.brightdata.com/billing/autorecharge")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brightdata.com/billing/autorecharge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"regular": {
"available": true,
"enabled": true,
"pmethod_id": "<string>",
"amount": 123,
"threshold": 123,
"limits": {
"min_amount": 123,
"max_amount": 123
}
},
"dataset": {
"available": true,
"enabled": true,
"pmethod_id": "<string>"
},
"suspended": true
}User authentication is requiredYour API key lacks the required permissions for this action. You can change your token permissions at https://brightdata.com/cp/setting/users<string>GET /billing/autorecharge 端点返回 Bright Data 账户的自动充值设置:regular 部分、dataset 部分,以及账户的自动充值是否被暂停(suspended)。
将您的 API key 粘贴到授权字段中。要获取 API key,请创建账号,并查看如何生成新的 API key?
此端点需要哪种 API key 权限?
GET /billing/autorecharge 需要 billing.read 权限。具有管理员或财务权限级别的 API key 拥有该权限。缺少该权限时,端点返回 HTTP 403 和纯文本消息。请在账户设置中管理 API key 权限。
如何检查自动充值是否已开启?
调用GET /billing/autorecharge。此端点不接受任何参数:
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.brightdata.com/billing/autorecharge"
regular.enabled 为 true 时,常规自动充值已开启。dataset.enabled 为 true 时,数据集自动充值已开启。suspended 为 true 时,整个账户的自动充值被暂停。
regular 部分返回哪些字段?
regular 对象包含常规自动充值设置:
| 字段 | 类型 | 说明 |
|---|---|---|
available | boolean | 账户可使用常规自动充值,且账户中有支持自动充值的支付方式时为 true |
enabled | boolean | 常规自动充值已开启时为 true |
pmethod_id | string 或 null | 自动充值扣款的支付方式。停用时为 null |
amount | integer 或 null | 充值金额,单位为美元。停用时为 null |
threshold | number 或 null | 触发充值的余额水平。当可用余额低于 ceil(amount / 4) 时开始充值。停用时为 null |
limits.min_amount | integer | 最低 amount,单位为美元。所有账户均为 $50 |
limits.max_amount | integer | 最高 amount,单位为美元。取决于公司类型,也可以按账户调整 |
amount 设置为 200 时,可用余额低于 $50 时开始充值。每次扣款金额请参阅常规自动充值扣款多少?。
dataset 部分返回哪些字段?
dataset 对象包含数据集自动充值设置:
| 字段 | 类型 | 说明 |
|---|---|---|
available | boolean | 可使用常规自动充值且账户拥有数据集 zone 时为 true |
enabled | boolean | 数据集自动充值已开启时为 true |
pmethod_id | string 或 null | 数据集自动充值扣款的支付方式。停用时为 null |
为什么我的账户无法使用自动充值?
满足以下任一条件时,regular.available 为 false:
- 账户是 AWS Marketplace organic 账户
- 账户是 IBM 账户
- 账户没有支持自动充值的支付方式,或所有此类支付方式均被冻结
dataset.available 也为 false。即使 available 为 false,也始终可以关闭自动充值。
账单端点有哪些速率限制?
账单端点允许每分钟 1,000 个请求、每小时 5,000 个请求。超出限制时,端点返回 HTTP 429 和纯文本响应体。相关端点
授权
在 Authorization 头中使用您的 Bright Data API Key 作为 Bearer token。
认证方法:
- 从 Bright Data 账户设置获取您的 API Key: https://brightdata.com/cp/setting/users
- 在请求的 Authorization 头中包含 API Key
- 格式:
Authorization: Bearer YOUR_API_KEY
示例:
Authorization: Bearer b5648e1096c6442f60a6c4bbbe73f8d2234d3d8324554bd6a7ec8f3f251f07df
了解如何获取 Bright Data API Key: https://docs.brightdata.com/cn/api-reference/authentication#如何生成新的-api-key?
此页面对您有帮助吗?