---
title: "การเรียก API ครั้งแรก | Tajo"
description: "เรียก Brevo API เป็นครั้งแรกและตรวจสอบว่าการตั้งค่าของคุณทำงานถูกต้อง"
url: https://tajo.io/th/docs/quick-start/first-api-call/
markdown: https://tajo.io/th/docs/quick-start/first-api-call.md
lang: th-TH
author: "Set Noa"
author_url: https://tajo.io/th/set-noa/
robots: noindex
---

ขอสิทธิ์ใช้งานล่วงหน้า

กรอกชื่อและที่อยู่อีเมลที่ทำงานของคุณ เราจะส่งลิงก์เพื่อยืนยันคำขอเข้าใช้งาน Tajo ทางอีเมล

# การเรียก API ครั้งแรก

[Set Noa](https://tajo.io/th/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/th/docs/authentication/) ให้เรียบร้อย
2. [ติดตั้ง SDK](https://tajo.io/th/docs/sdks-libraries/) สำหรับภาษาที่คุณใช้
3. [ทำความเข้าใจขีดจำกัดอัตราการเรียก](https://tajo.io/th/docs/rate-limits/)
4. [สำรวจ endpoint สำหรับอีเมล](https://tajo.io/th/docs/email-messaging/)
