brightdata-sdk

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Bright Data SDKs

Bright Data SDKs

Two published packages, one skill. The request is the same in both languages, so follow the language the repo already uses.
LanguagePackageRegistryInstall
Python
brightdata-sdk
PyPI
pip install brightdata-sdk
Node.js
@brightdata/sdk
npm
npm install @brightdata/sdk
两个已发布的包,一个 skill。两种语言中的请求相同,因此应遵循代码仓库已经使用的语言。
语言包注册表安装
Python
brightdata-sdk
PyPI
pip install brightdata-sdk
Node.js
@brightdata/sdk
npm
npm install @brightdata/sdk

Which reference to open

应打开哪个参考文件

  • A
    pyproject.toml
    , a
    requirements.txt
    or
    .py
    files are in the project: open
    references/python.md
    .
  • A
    package.json
    or
    .js
    ,
    .mjs
    and
    .ts
    files are in the project: open
    references/nodejs.md
    .
  • Both languages are present and neither clearly owns the job: ask which runtime will run it, then open that one file.
  • 项目中存在
    pyproject.toml
    、
    requirements.txt
    或
    .py
    文件:打开
    references/python.md
    。
  • 项目中存在
    package.json
    或
    .js
    、
    .mjs
    、
    .ts
    文件:打开
    references/nodejs.md
    。
  • 项目中同时存在两种语言,且没有明确哪一种负责运行:询问用户将使用哪个 runtime,然后打开对应的文件。

When the SDK is the right surface

何时应使用 SDK

The user keeps the code. A cron job, a backend service, an ETL step, an enrichment pipeline: anything where the same call runs again and again from a file under version control. Reach for the SDK the moment a Bright Data call is going to live in a repo rather than in a terminal.
Two neighbours own the other cases. A one-off check typed at a shell is
brightdata-cli
. An AI app that picks its tools at run time is
brightdata-mcp
.
用户会保留代码。定时任务、后端服务、ETL 步骤、数据增强流水线:任何从版本控制中的文件反复执行同一次调用的场景。只要 Bright Data 调用将放在代码仓库中而不是终端里,就应使用 SDK。
另外两个相邻 skill 分别负责其他场景。在 shell 中临时输入的一次性检查使用
brightdata-cli
。在运行时自主选择工具的 AI 应用使用
brightdata-mcp
。

Auth

身份验证

Install, login and API key problems belong to
agent-onboarding
, which owns credential paths and what a refused call means. See its
references/auth.md
.
The one fact this skill needs: both SDKs read
BRIGHTDATA_API_TOKEN
first, accept
BRIGHTDATA_API_KEY
as an alternate, and fall back to the credentials the Bright Data CLI stored at login. Never write a key into source. Both reference files show the key coming from the environment. To check that a key exists, run
node scripts/check-auth.mjs
from the
agent-onboarding
skill; never
cat
,
echo
or
jq
the credentials file or the variable, because whatever a command prints lands in the conversation and its logs.
安装、登录和 API key 问题属于
agent-onboarding
,该 skill 负责凭据路径以及调用被拒绝时的含义。参阅它的
references/auth.md
。
本 skill 只需要了解一件事:两个 SDK 都会优先读取
BRIGHTDATA_API_TOKEN
,接受
BRIGHTDATA_API_KEY
作为替代项,并在找不到它们时回退到 Bright Data CLI 登录时保存的凭据。切勿将 key 写入源代码。两份参考文件都展示了如何从环境变量获取 key。要检查 key 是否存在,请从
agent-onboarding
skill 中运行
node scripts/check-auth.mjs
;切勿使用
cat
、
echo
或
jq
输出凭据文件或变量内容,因为命令打印的任何内容都会进入对话及其日志。

What both packages cover

两个包涵盖的功能

Page fetch, SERP search, per-platform scrapers, a crawler, dataset access, Browser API connect strings, and a Scraper Studio namespace. The shape differs by language: Python is async first and uses snake_case, Node.js uses camelCase and has to be closed, either with
close()
by hand or with
await using
on modern runtimes. Read the reference file rather than translating method names by hand.
By default both SDKs create the zones
sdk_unlocker
and
sdk_serp
in the account when they are missing: Python when the client opens, Node on the first call that uses each zone. Tell the user before running code that will do that. Each reference file shows how to turn auto-creation off and use the account's own zones.
页面获取、SERP 搜索、各平台 scraper、crawler、数据集访问、Browser API connect string,以及 Scraper Studio namespace。两种语言的接口形态不同:Python 以 async 为优先,并使用 snake_case;Node.js 使用 camelCase,并且必须关闭客户端,可以手动调用
close()
,也可以在现代 runtime 中使用
await using
。请阅读对应的参考文件,不要手工翻译方法名称。
默认情况下,如果账户中不存在
sdk_unlocker
和
sdk_serp
,两个 SDK 都会创建它们:Python 在客户端打开时创建,Node.js 在首次调用使用相应 zone 的功能时创建。运行将执行此操作的代码前,应先告知用户。每份参考文件都展示了如何关闭自动创建并使用账户自己的 zones。