---
title: "第一次 API 调用 | Tajo"
description: "完成第一次 Brevo API 调用，验证你的配置是否正确"
url: https://tajo.io/zh-cn/docs/quick-start/first-api-call/
markdown: https://tajo.io/zh-cn/docs/quick-start/first-api-call.md
lang: zh-CN
author: "Set Noa"
author_url: https://tajo.io/zh-cn/set-noa/
robots: noindex
---

申请抢先体验

请输入您的名字和公司电子邮箱地址。我们会发送确认 Tajo 访问申请的链接。

# 第一次 API 调用

[Set Noa](https://tajo.io/zh-cn/set-noa/)

下面完成第一次 API 调用，验证你的 Brevo API 配置是否正常工作。

## 前置条件

- 一个 Brevo 账号
- 从仪表板获取的 API 密钥
- 一个发送 HTTP 请求的工具（curl、Postman 或类似工具）

## 获取账户信息

最简单的第一次调用是获取账户信息：

### 使用 cURL

```bash
curl -X GET "https://api.brevo.com/v3/account" \
  -H "Accept: application/json" \
  -H "api-key: YOUR_API_KEY"
```

### 使用 JavaScript（Node.js）

```javascript
const fetch = require('node-fetch');

const getAccount = async () => {
  try {
    const response = await fetch('https://api.brevo.com/v3/account', {
      method: 'GET',
      headers: {
        'Accept': 'application/json',
        'api-key': 'YOUR_API_KEY'
      }
    });

    const data = await response.json();
    console.log('Account Info:', data);
  } catch (error) {
    console.error('Error:', error);
  }
};

getAccount();
```

### 使用 Python

```python
import requests

url = "https://api.brevo.com/v3/account"
headers = {
    "Accept": "application/json",
    "api-key": "YOUR_API_KEY"
}

response = requests.get(url, headers=headers)
print(response.json())
```

### 使用 PHP

```php
<?php
$url = 'https://api.brevo.com/v3/account';
$headers = [
    'Accept: application/json',
    'api-key: YOUR_API_KEY'
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

## 预期响应

调用成功后，你会收到类似下面的响应：

```json
{
  "email": "your-email@company.com",
  "firstName": "John",
  "lastName": "Doe",
  "companyName": "Your Company",
  "address": {
    "street": "123 Main Street",
    "city": "New York",
    "zipCode": "10001",
    "country": "United States"
  },
  "plan": [
    {
      "type": "payAsYouGo",
      "credits": 10000,
      "creditsUsed": 1500
    }
  ]
}
```

## 错误处理

如果遇到错误，请排查以下常见问题：

### API 密钥无效（401 Unauthorized）

```json
{
  "code": "unauthorized",
  "message": "Invalid API key provided"
}
```

**解决办法**：确认 API 密钥正确，且具备所需权限。

### 超出速率限制（429 Too Many Requests）

```json
{
  "code": "too_many_requests",
  "message": "Rate limit exceeded"
}
```

**解决办法**：等待一段时间再发起请求，或升级你的套餐。

### 服务器错误（500 Internal Server Error）

```json
{
  "code": "internal_error",
  "message": "An internal error occurred"
}
```

**解决办法**：查看 [状态页面](https://status.brevo.com/) 或联系支持团队。

## 后续步骤

第一次 API 调用成功之后，接下来可以：

1. 正确地 [设置身份验证](https://tajo.io/zh-cn/docs/authentication/)
2. 为你使用的语言 [安装 SDK](https://tajo.io/zh-cn/docs/sdks-libraries/)
3. [了解速率限制](https://tajo.io/zh-cn/docs/rate-limits/)
4. [查看邮件相关端点](https://tajo.io/zh-cn/docs/email-messaging/)
