> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 介绍

> Dodo Payments API 提供全面的支付处理、订阅管理和数字产品交付的端点。我们的 RESTful API 遵循行业标准，所有操作都有详细的响应。

<Card title="SDKs & Libraries" icon="code" href="/developer-resources/dodo-payments-sdks">
  通过使用适用于 <strong>TypeScript</strong>、<strong>Python</strong>、<strong>Go</strong>、<strong>PHP</strong>、<strong>Java</strong>、<strong>Kotlin</strong>、<strong>C#</strong>、<strong>Ruby</strong> 和 <strong>React Native</strong> 的官方 SDK 加快您的集成。这些库简化了 API 请求、身份验证和错误处理，让您能够专注于构建出色的支付体验。
</Card>

## 环境 URL

* **测试模式**: [`https://test.dodopayments.com`](https://test.dodopayments.com)
* **实时模式**: [`https://live.dodopayments.com`](https://live.dodopayments.com)

<Note>
  了解更多关于[测试模式与实时模式](/miscellaneous/test-mode-vs-live-mode)的信息。
</Note>

## API 密钥管理和身份验证

<Steps>
  <Step title="Access API Keys">
    在仪表板中导航至 **开发者 → API 密钥** 来管理您的密钥。
  </Step>

  <Step title="Generate a New Key">
    选择 **添加 API 密钥**，提供一个描述性名称，并配置写入权限：

    * **启用写入权限**（已勾选）：对所有 API 操作具有完全的读写权限
    * **启用写入权限**（未勾选）：只读访问 - 只能获取数据（支付、订阅、客户、产品）。无法创建或修改资源。

    <Tip>
      对于仅需查看数据而不进行更改的仪表板集成、分析工具以及其他系统，请取消选中“启用写入权限”。
    </Tip>
  </Step>

  <Step title="Store Your Key Securely">
    立即复制生成的密钥并确保其安全存放。
  </Step>

  <Step title="Authenticate Your API Requests">
    使用您的 API 密钥对所有请求进行身份验证。采用以下授权格式：

    ```bash theme={null}
    Authorization: Bearer YOUR_API_KEY
    ```

    <Warning>
      切勿在客户端代码或公开仓库中暴露您的秘密 API 密钥。
    </Warning>
  </Step>
</Steps>

## 响应格式

<CodeGroup>
  ```json Success Response theme={null}
  {
    "id": "pay_1234567890",
    "status": "completed",
    "amount": 2999,
    "currency": "USD",
    "created_at": "2024-01-15T10:30:00Z"
  }
  ```

  ```json Error Response theme={null}
  {
    "code": "INVALID_REQUEST",
    "message": "The request contains invalid parameters"
  }
  ```
</CodeGroup>

## 速率限制

我们的 API 使用具有突发保护功能的双窗口速率限制系统。限额基于您的身份验证方式和业务等级来应用。

### 默认限额（等级 0）

| 窗口      | 限额      |
| ------- | ------- |
| 每秒（突发）  | 40 次请求  |
| 每分钟（持续） | 240 次请求 |

### 业务等级

对于拥有更高 API 需求的企业可获取更高的速率限制：

| 等级       | 突发（每秒） | 持续（每分钟） |
| -------- | ------ | ------- |
| 等级 0（默认） | 40     | 240     |
| 等级 1     | 100    | 1,000   |
| 等级 2     | 500    | 5,000   |

<Tip>
  联系支持以将您的业务升级到更高的速率限制等级。
</Tip>

### 未经身份验证的请求

不带有效身份验证头的请求按 IP 地址限速：

| 窗口      | 限额      |
| ------- | ------- |
| 每秒（突发）  | 20 次请求  |
| 每分钟（持续） | 100 次请求 |

### 速率限制响应头

通过以下响应头监控您的使用情况：

* `X-RateLimit-Limit` - 允许的最大请求数
* `X-RateLimit-Remaining` - 当前窗口中剩余的请求数
* `X-RateLimit-Reset` - 速率限制重置的时间

<Note>
  当您超过速率限制时，API 会返回 `429 Too Many Requests` 响应。请在重试逻辑中实现指数退避。
</Note>

## 错误处理

若要有效管理错误，请参阅 *错误代码* 和 *交易失败* 部分以获取详细指导。

<CardGroup cols={2}>
  <Card title="Error Codes" icon="triangle-exclamation" href="/api-reference/error-codes">
    深入了解全面的错误细节及其解决方案。
  </Card>

  <Card title="Transaction Failures" icon="circle-exclamation" href="/api-reference/transaction-failures">
    了解常见交易问题及其解决方法。
  </Card>
</CardGroup>

## Webhooks

接收有关支付事件的实时通知。请参阅我们的[Webhook 指南](/developer-resources/webhooks)以获取设置说明。

<Card title="Webhook Guide" icon="webhook" href="/developer-resources/webhooks">
  设置 Webhooks 以获取实时通知和事件处理。
</Card>

## 相关开发者指南

探索我们全面的指南，了解如何使用API实现关键功能：

Learn how to integrate one-time payments, checkout sessions, and payment links into your application
Complete guide to implementing subscriptions, managing plans, and handling subscription lifecycle events
Set up meters and usage events for metered billing and consumption-based pricing models
Receive real-time notifications and automate workflows with webhook events
Create secure, hosted checkout experiences with full customization and advanced features
