curl --request POST \
--url https://api.brightdata.com/request \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"zone": "<string>",
"url": "<string>",
"method": "GET",
"country": "<string>",
"city": "<string>",
"zip": "<string>",
"ASN": "<string>",
"carrier": "<string>",
"os": "<string>",
"session": "<string>",
"ip": "<string>",
"gip": "<string>",
"c_tag": "<string>",
"direct": true
}
'import requests
url = "https://api.brightdata.com/request"
payload = {
"zone": "<string>",
"url": "<string>",
"method": "GET",
"country": "<string>",
"city": "<string>",
"zip": "<string>",
"ASN": "<string>",
"carrier": "<string>",
"os": "<string>",
"session": "<string>",
"ip": "<string>",
"gip": "<string>",
"c_tag": "<string>",
"direct": True
}
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({
zone: '<string>',
url: '<string>',
method: 'GET',
country: '<string>',
city: '<string>',
zip: '<string>',
ASN: '<string>',
carrier: '<string>',
os: '<string>',
session: '<string>',
ip: '<string>',
gip: '<string>',
c_tag: '<string>',
direct: true
})
};
fetch('https://api.brightdata.com/request', 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/request",
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([
'zone' => '<string>',
'url' => '<string>',
'method' => 'GET',
'country' => '<string>',
'city' => '<string>',
'zip' => '<string>',
'ASN' => '<string>',
'carrier' => '<string>',
'os' => '<string>',
'session' => '<string>',
'ip' => '<string>',
'gip' => '<string>',
'c_tag' => '<string>',
'direct' => true
]),
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/request"
payload := strings.NewReader("{\n \"zone\": \"<string>\",\n \"url\": \"<string>\",\n \"method\": \"GET\",\n \"country\": \"<string>\",\n \"city\": \"<string>\",\n \"zip\": \"<string>\",\n \"ASN\": \"<string>\",\n \"carrier\": \"<string>\",\n \"os\": \"<string>\",\n \"session\": \"<string>\",\n \"ip\": \"<string>\",\n \"gip\": \"<string>\",\n \"c_tag\": \"<string>\",\n \"direct\": true\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/request")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"zone\": \"<string>\",\n \"url\": \"<string>\",\n \"method\": \"GET\",\n \"country\": \"<string>\",\n \"city\": \"<string>\",\n \"zip\": \"<string>\",\n \"ASN\": \"<string>\",\n \"carrier\": \"<string>\",\n \"os\": \"<string>\",\n \"session\": \"<string>\",\n \"ip\": \"<string>\",\n \"gip\": \"<string>\",\n \"c_tag\": \"<string>\",\n \"direct\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brightdata.com/request")
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 \"zone\": \"<string>\",\n \"url\": \"<string>\",\n \"method\": \"GET\",\n \"country\": \"<string>\",\n \"city\": \"<string>\",\n \"zip\": \"<string>\",\n \"ASN\": \"<string>\",\n \"carrier\": \"<string>\",\n \"os\": \"<string>\",\n \"session\": \"<string>\",\n \"ip\": \"<string>\",\n \"gip\": \"<string>\",\n \"c_tag\": \"<string>\",\n \"direct\": true\n}"
response = http.request(request)
puts response.read_body"OK""错误请求""需要用户身份验证"Proxy REST API playground
Send proxied requests through the Bright Data Proxy REST API using a single POST endpoint on port 44445. Includes an interactive playground for testing.
curl --request POST \
--url https://api.brightdata.com/request \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"zone": "<string>",
"url": "<string>",
"method": "GET",
"country": "<string>",
"city": "<string>",
"zip": "<string>",
"ASN": "<string>",
"carrier": "<string>",
"os": "<string>",
"session": "<string>",
"ip": "<string>",
"gip": "<string>",
"c_tag": "<string>",
"direct": true
}
'import requests
url = "https://api.brightdata.com/request"
payload = {
"zone": "<string>",
"url": "<string>",
"method": "GET",
"country": "<string>",
"city": "<string>",
"zip": "<string>",
"ASN": "<string>",
"carrier": "<string>",
"os": "<string>",
"session": "<string>",
"ip": "<string>",
"gip": "<string>",
"c_tag": "<string>",
"direct": True
}
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({
zone: '<string>',
url: '<string>',
method: 'GET',
country: '<string>',
city: '<string>',
zip: '<string>',
ASN: '<string>',
carrier: '<string>',
os: '<string>',
session: '<string>',
ip: '<string>',
gip: '<string>',
c_tag: '<string>',
direct: true
})
};
fetch('https://api.brightdata.com/request', 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/request",
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([
'zone' => '<string>',
'url' => '<string>',
'method' => 'GET',
'country' => '<string>',
'city' => '<string>',
'zip' => '<string>',
'ASN' => '<string>',
'carrier' => '<string>',
'os' => '<string>',
'session' => '<string>',
'ip' => '<string>',
'gip' => '<string>',
'c_tag' => '<string>',
'direct' => true
]),
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/request"
payload := strings.NewReader("{\n \"zone\": \"<string>\",\n \"url\": \"<string>\",\n \"method\": \"GET\",\n \"country\": \"<string>\",\n \"city\": \"<string>\",\n \"zip\": \"<string>\",\n \"ASN\": \"<string>\",\n \"carrier\": \"<string>\",\n \"os\": \"<string>\",\n \"session\": \"<string>\",\n \"ip\": \"<string>\",\n \"gip\": \"<string>\",\n \"c_tag\": \"<string>\",\n \"direct\": true\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/request")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"zone\": \"<string>\",\n \"url\": \"<string>\",\n \"method\": \"GET\",\n \"country\": \"<string>\",\n \"city\": \"<string>\",\n \"zip\": \"<string>\",\n \"ASN\": \"<string>\",\n \"carrier\": \"<string>\",\n \"os\": \"<string>\",\n \"session\": \"<string>\",\n \"ip\": \"<string>\",\n \"gip\": \"<string>\",\n \"c_tag\": \"<string>\",\n \"direct\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.brightdata.com/request")
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 \"zone\": \"<string>\",\n \"url\": \"<string>\",\n \"method\": \"GET\",\n \"country\": \"<string>\",\n \"city\": \"<string>\",\n \"zip\": \"<string>\",\n \"ASN\": \"<string>\",\n \"carrier\": \"<string>\",\n \"os\": \"<string>\",\n \"session\": \"<string>\",\n \"ip\": \"<string>\",\n \"gip\": \"<string>\",\n \"c_tag\": \"<string>\",\n \"direct\": true\n}"
response = http.request(request)
puts response.read_body"OK""错误请求""需要用户身份验证"Authorizations
在 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?
Body
将为您的请求提供服务的代理区域名称。
请求的目标 URL。
通过代理请求原始 HTML 的格式为 raw。
请求 JSON 响应的格式为 json。
raw, json 通过代理请求 HTML 的方法为 GET。
请求通过的代理所在的国家代码。
请求通过的代理所在的城市名称,必须定义国家。
在数据中心和 ISP 区域中支持预配置城市,在住宅和移动网络中默认支持。
请求通过的代理所在的邮政编码,必须定义国家。
仅在住宅网络中支持。
请求通过的代理所在的 ASN 代码,必须定义国家。
仅在住宅网络中支持。
仅适用于移动网络:请求通过的运营商代码。
仅在移动网络中支持。
设置在代理上的客户端操作系统。
仅在移动网络中支持。
使用 local 或 remote 设置域名映射是在客户端本地还是在远程代理节点上完成。
local, remote 客户端传递的字符串以标记会话,所有具有相同 session 参数的请求将被传递到相同的代理节点。
在数据中心和 ISP 区域中:将请求转发到由 ip 标识的特定代理。
在 住宅 和 移动 区域中:将请求转发到由 gip 标识的特定代理组。
在请求中包含唯一的 c_tag 标志。响应中,业务端会在头部返回相同的标志。此无缝交换确保每个响应都绑定到其对应的请求,消除混淆并简化数据管理。
将参数设置为 true 会指示通过 Bright Data 超级代理(数据中心代理,而非代理节点本身)处理请求。
Response
成功
The response is of type string.
"OK"
Was this page helpful?