# 通过 API 方式获取代理

本指南介绍如何使用Rapidproxy 的**API 获取**方法获取动态（轮换）住宅代理。通过 API 获取，您可以根据所选参数生成代理 API 链接，并将其直接集成到您的应用程序中。

***

#### 概述 <a href="#overview" id="overview"></a>

API**获取**方法允许您通过在控制面板中配置代理参数来动态生成代理访问链接。

使用这种方法，您可以：

* 定义 IP 数量和目标位置
* 选择代理协议和输出格式
* 生成可直接使用的 API 链接
* 复制 API 链接并将其集成到脚本或工具中

***

#### 访问 API 获取 <a href="#accessing-api-acquisition" id="accessing-api-acquisition"></a>

要打开 API 获取设置：

1. [登录您的 Rapidproxy 帐户](https://www.rapidproxy.io/user/login)。
2. 前往**UCenter**。
3. 导航至： **Rotating Residential Proxies → Use Proxy → API Method（轮换住宅代理 → 使用代理 → API 方法）**

<figure><img src="https://docs.rapidproxy.io/~gitbook/image?url=https%3A%2F%2F3714437495-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FYesC7FUvYuYg4WiqU6o7%252Fuploads%252FVGgO2xPz6FUsReZjVZGw%252Fapimethod.png%3Falt%3Dmedia%26token%3D125c6c89-0e09-498f-8921-2456274e51b7&#x26;width=768&#x26;dpr=3&#x26;quality=100&#x26;sign=d97c4abc&#x26;sv=2" alt=""><figcaption></figcaption></figure>

此页面包含生成代理 API 链接所需的所有可用设置。

***

#### API 获取设置 <a href="#api-acquisition-setup" id="api-acquisition-setup"></a>

请按照以下步骤配置并生成您的代理 API 链接。

***

**步骤 1：设置 IP 数量和区域**

在**API 方法**页面上：

1. 设置**IP 数量**（要检索的代理 IP 数量）。
2. 根据您的需要选择所需的**地区/国家。**

这些设置决定您接收的 IP 地址数量以及来自哪些位置。

<figure><img src="https://docs.rapidproxy.io/~gitbook/image?url=https%3A%2F%2F3714437495-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FYesC7FUvYuYg4WiqU6o7%252Fuploads%252FoJ18h8MPFiH3CVomBnkf%252Fapiacquisition.png%3Falt%3Dmedia%26token%3D43122e58-45ab-4411-ba6c-54d9e1d87d88&#x26;width=768&#x26;dpr=3&#x26;quality=100&#x26;sign=4cebcef8&#x26;sv=2" alt=""><figcaption></figcaption></figure>

***

**步骤 2：配置 API 参数**

接下来，配置输出和协议选项：

* **代理协议** 选择您要使用的协议（例如 HTTP(S) 或 SOCKS5）。
* **数据格式** 选择代理数据将以何种格式返回（例如，纯文本或结构化格式）。
* **分隔符** 选择用于分隔输出中代理字段的分隔符。

这些选项控制 API 如何返回代理信息。

***

**步骤 3：生成 API 链接**

完成所有设置后：

1. 点&#x51FB;**“生成结果”**。
2. 系统将根据您的配置生成**代理 API 链接。**
3. 点击生成的链接即可**复制**。

<figure><img src="https://docs.rapidproxy.io/~gitbook/image?url=https%3A%2F%2F3714437495-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FYesC7FUvYuYg4WiqU6o7%252Fuploads%252FDzuOaer3PcIkpLQ8ztDd%252Fgenerrate.png%3Falt%3Dmedia%26token%3Dc9fb5bdb-e664-4d96-9727-9d157abffb8f&#x26;width=768&#x26;dpr=3&#x26;quality=100&#x26;sign=f685f95e&#x26;sv=2" alt=""><figcaption></figcaption></figure>

现在您可以直接在应用程序、脚本或代理管理工具中使用此 API 链接。

***

#### 使用生成的 API 链接 <a href="#using-the-generated-api-link" id="using-the-generated-api-link"></a>

复制后，API 链接可以这样使用：

* 嵌入到自动化脚本中
* 用于启用代理的工具
* 集成到抓取框架或应用程序中

只要您的**IP 地址已**[**加入白名单**](https://docs.rapidproxy.io/proxies/dynamic-residential-proxy/get-proxy/api/ip-whitelisting)，API 链接就会根据您的配置返回有效的代理数据。

***

#### 注意事项和最佳实践 <a href="#notes-and-best-practices" id="notes-and-best-practices"></a>

* 使用 API 之前，请确保已将您的**出站 IP 地址添加到白名单中。**
* 如果您的服务器 IP 地址发生更改，请相应地更新白名单。
* 您可以随时通过调整参数并再次单击 **Generate results （生成结果）**&#x6765;重新生成 API 链接。

***

#### 需要帮助吗？ <a href="#need-help" id="need-help"></a>

如果您对 API 获取或代理设置有任何疑问：

* 请使用Rapidproxy 网站上的**在线实时聊天**功能
* 请发送电子邮件**至 <support@rapidproxy.io>**

支持团队可以协助解决配置、身份验证和 API 使用方面的问题。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rapidproxy.io/simplified-mandarin/dai-li/dong-tai-zhu-zhai-dai-li/huo-qu-dai-li/api/tong-guo-api-fang-shi-huo-qu-dai-li.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
