cURL
curl --request GET \
--url https://api.brightdata.com/billing/pmethods \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.brightdata.com/billing/pmethods"
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/pmethods', 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/pmethods",
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/pmethods"
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/pmethods")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brightdata.com/billing/pmethods")
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{
"pmethods": [
{
"id": "64f0c2a1e4b0a1b2c3d4e5f6",
"type": "ccard",
"primary": true,
"autorecharge_supported": true,
"card": {
"brand": "visa",
"last4": "4242",
"exp_month": 6,
"exp_year": 2028
},
"paypal": {
"email": "jsmith@example.com"
}
}
]
}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/pmethods 列出账户中已激活且已确认的支付方式,以及每种支付方式是否支持自动充值。
GET
/
billing
/
pmethods
cURL
curl --request GET \
--url https://api.brightdata.com/billing/pmethods \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.brightdata.com/billing/pmethods"
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/pmethods', 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/pmethods",
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/pmethods"
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/pmethods")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brightdata.com/billing/pmethods")
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{
"pmethods": [
{
"id": "64f0c2a1e4b0a1b2c3d4e5f6",
"type": "ccard",
"primary": true,
"autorecharge_supported": true,
"card": {
"brand": "visa",
"last4": "4242",
"exp_month": 6,
"exp_year": 2028
},
"paypal": {
"email": "jsmith@example.com"
}
}
]
}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/pmethods 端点返回 Bright Data 账户中已激活且已确认的支付方式。使用支付方式的 id,可通过设置常规自动充值或设置数据集自动充值开启自动充值。
将您的 API key 粘贴到授权字段中。要获取 API key,请创建账号,并查看如何生成新的 API key?
此端点需要哪种 API key 权限?
GET /billing/pmethods 需要 billing.read 权限。具有管理员或财务权限级别的 API key 拥有该权限。缺少该权限时,端点返回 HTTP 403 和纯文本消息。请在账户设置中管理 API key 权限。
如何列出我的支付方式?
调用GET /billing/pmethods。此端点不接受任何参数:
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.brightdata.com/billing/pmethods"
pmethods 数组,每种支付方式对应一个条目。
响应结构是怎样的?
pmethods 数组中的每个条目描述一种支付方式:
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 支付方式 ID。将此值作为 pmethod_id 传给自动充值端点 |
type | string | 支付方式类型,例如 ccard |
primary | boolean | 账户的主要支付方式为 true |
autorecharge_supported | boolean | API 可以使用此支付方式开启自动充值时为 true |
card | object | 仅限银行卡支付方式:brand、last4、exp_month 和 exp_year |
paypal | object | 仅限 PayPal 支付方式:email |
哪些支付方式可用于自动充值?
使用autorecharge_supported 为 true 的支付方式。如只需输出这些支付方式,可使用 jq 过滤响应:
curl -s -H "Authorization: Bearer YOUR_API_KEY" \
"https://api.brightdata.com/billing/pmethods" \
| jq '.pmethods[] | select(.autorecharge_supported)'
error_code 为 pmethod_not_supported。
账单端点有哪些速率限制?
账单端点允许每分钟 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?
此页面对您有帮助吗?