# เอกสารอ้างอิง SERP API: GET /search และ GET /credits

> เอกสารอ้างอิง SerpCrypto SERP API: พารามิเตอร์ GET /search, เอนจิน, ค่าเริ่มต้น, บล็อกการตอบกลับ, รหัสข้อผิดพลาด และ GET /credits พร้อม curl, Python และ Node.js

- URL: https://serpcrypto.com/th/docs/search/
- อัปเดตล่าสุด: 2026-10-22
- ผู้เผยแพร่: SerpCrypto (https://serpcrypto.com)

ทุกพารามิเตอร์ ค่าเริ่มต้น และรหัสข้อผิดพลาดของ API SerpCrypto เวอร์ชัน 1 Base URL: `https://serpcrypto.com/api/v1` ทุกคำขอใช้ HTTPS และทุกคำตอบเป็น JSON ใน UTF-8

**คำตอบสั้น — endpoint ค้นหาของ SerpCrypto รับพารามิเตอร์อะไรบ้าง?**

`GET https://serpcrypto.com/api/v1/search` รับพารามิเตอร์ที่จำเป็นหนึ่งตัวคือ `q` และพารามิเตอร์เสริมเก้าตัว: `engine`, `gl`, `hl`, `location`, `google_domain`, `device`, `page`, `safe` และ `period` **SerpCrypto** คืนค่าเป็น JSON และคิด 1 เครดิตต่อการค้นหาที่สำเร็จบนทุก 6 เอนจิน ส่วนข้อผิดพลาดฟรี แพ็กเริ่มต้นที่ US$7.50 สำหรับ 10,000 การค้นหา จ่ายด้วยคริปโต ไม่ต้อง KYC

## จะยืนยันตัวตนอย่างไร?

ส่งคีย์ของคุณได้สองวิธี วิธีที่แนะนำคือ header `Authorization: Bearer YOUR_KEY` อีกวิธีคือ query parameter `api_key=YOUR_KEY` ซึ่งสะดวกสำหรับทดสอบเร็ว ๆ ในแท็บเบราว์เซอร์

คีย์ที่หายไป ผิด หรือถูกเพิกถอนจะได้ `401 invalid_api_key` และไม่มีค่าใช้จ่าย API key ที่คุณสร้างและเพิกถอนได้ทุกเมื่อจากแดชบอร์ดของคุณ ดังนั้นคุณจึงให้แต่ละสคริปต์หรือเซิร์ฟเวอร์มีคีย์ของตัวเอง และเพิกถอนคีย์หนึ่งโดยไม่กระทบคีย์อื่นได้

## รันการค้นหา

`GET /api/v1/search`

รันการค้นหาหนึ่งครั้งบนเอนจินที่เลือกและคืนหน้าผลลัพธ์เป็น JSON การค้นหาที่สำเร็จใช้ 1 เครดิต ไม่ว่าเอนจินใด ส่วนข้อผิดพลาดไม่ใช้เลย พารามิเตอร์ใส่ใน query string แบบ URL-encoded ตัวอย่างค้นหา Google หาโรงคั่วกาแฟใน Austin, Texas ส่วน ID จำนวน และผลลัพธ์เป็นเพียงตัวอย่าง

การยืนยันตัวตน: API key ใน header `Authorization: Bearer API_KEY`

**พารามิเตอร์**

| ชื่อ | In | Type | Required | คำอธิบาย |
| --- | --- | --- | --- | --- |
| `q` | query | string | ใช่ | คำค้นหา ตามที่คนพิมพ์จริง ผู้ดำเนินการค้นหา เช่น เครื่องหมายคำพูด หรือ `site:` ถือเป็นส่วนหนึ่งของคำค้นหา |
| `engine` | query | string | ไม่ใช่ | `google` (ค่าเริ่มต้น), `google_news`, `google_images`, `google_maps`, `google_shopping` หรือ `bing` |
| `gl` | query | string | ไม่ใช่ | ประเทศของผลลัพธ์: รหัส ISO 3166-1 alpha-2 ตัวพิมพ์เล็ก เช่น `us`, `de` หรือ `br` ค่าเริ่มต้น `us` |
| `hl` | query | string | ไม่ใช่ | ภาษาของอินเทอร์เฟซ เช่น `en`, `de` หรือ `pt-BR` ค่าเริ่มต้น `en` |
| `location` | query | string | ไม่ใช่ | สถานที่ระดับเมือง เขียนเป็น `City, Region, Country` เช่น `Austin, Texas, United States` ดู [สถานที่](https://serpcrypto.com/th/docs/locations/) |
| `google_domain` | query | string | ไม่ใช่ | โดเมน Google ที่จะค้นหา เช่น `google.de` ค่าเริ่มต้น: โดเมนของประเทศ `gl` ถูกเพิกเฉยเมื่อ `engine=bing` |
| `device` | query | string | ไม่ใช่ | `desktop` (ค่าเริ่มต้น) หรือ `mobile` |
| `page` | query | integer | ไม่ใช่ | หน้าผลลัพธ์ตั้งแต่ 1 (ค่าเริ่มต้น) ถึง 10 แต่ละหน้าเป็นการค้นหาแยกกันและใช้ 1 เครดิต |
| `safe` | query | string | ไม่ใช่ | `active` กรองผลลัพธ์ที่ชัดเจนออก; `off` (ค่าเริ่มต้น) ไม่กรอง |
| `period` | query | string | ไม่ใช่ | เฉพาะผลลัพธ์จากชั่วโมงที่แล้ว (`h`), วัน (`d`), สัปดาห์ (`w`), เดือน (`m`) หรือปี (`y`) |
| `api_key` | query | string | ไม่ใช่ | API key ของคุณ หากคุณไม่ส่ง header `Authorization` |

**Response** `200`

```json
{
  "search_metadata": {
    "id": "srch_7f3a9c2e41b8",
    "status": "success",
    "engine": "google",
    "created_at": "2026-10-22T09:14:05Z",
    "credits_used": 1
  },
  "search_parameters": {
    "engine": "google",
    "q": "coffee roasters",
    "gl": "us",
    "hl": "en",
    "location": "Austin, Texas, United States",
    "google_domain": "google.com",
    "device": "desktop",
    "page": 1
  },
  "search_information": {
    "total_results": 18600000,
    "query_displayed": "coffee roasters"
  },
  "local_results": [
    {
      "position": 1,
      "title": "Example Coffee Roasters",
      "address": "123 Example St, Austin, TX",
      "rating": 4.7,
      "reviews": 312,
      "type": "Coffee roasters"
    }
  ],
  "organic_results": [
    {
      "position": 1,
      "title": "The 12 best coffee roasters in Austin",
      "link": "https://www.example.com/austin/coffee-roasters",
      "displayed_link": "www.example.com › austin › coffee",
      "snippet": "From light Nordic roasts to dark espresso blends, these local roasters…",
      "date": "Sep 30, 2026"
    },
    {
      "position": 2,
      "title": "Example Roasting Co. | Fresh beans, roasted in Austin",
      "link": "https://www.example.org/",
      "displayed_link": "www.example.org",
      "snippet": "Small-batch coffee roasted every weekday and shipped the same day…"
    }
  ],
  "people_also_ask": [
    {
      "question": "What is the oldest coffee roaster in Austin?",
      "snippet": "…",
      "title": "Austin coffee history",
      "link": "https://www.example.net/austin-coffee-history"
    }
  ],
  "related_searches": [
    {
      "query": "coffee roasters near me"
    },
    {
      "query": "coffee roasters austin wholesale"
    }
  ],
  "pagination": {
    "current": 1,
    "next_page": 2
  }
}
```

*curl*

```bash
curl -sG "https://serpcrypto.com/api/v1/search" \
  -H "Authorization: Bearer $SERPCRYPTO_API_KEY" \
  --data-urlencode "q=coffee roasters" \
  --data-urlencode "location=Austin, Texas, United States" \
  -d gl=us -d hl=en -d device=desktop
```

*Python*

```python
import os

import requests

r = requests.get(
    "https://serpcrypto.com/api/v1/search",
    params={
        "q": "coffee roasters",
        "location": "Austin, Texas, United States",
        "gl": "us",
        "hl": "en",
    },
    headers={"Authorization": "Bearer " + os.environ["SERPCRYPTO_API_KEY"]},
    timeout=60,
)
r.raise_for_status()
print(r.json()["organic_results"][0]["link"])
```

*Node.js*

```javascript
const params = new URLSearchParams({
  q: "coffee roasters",
  location: "Austin, Texas, United States",
  gl: "us",
  hl: "en",
});
const res = await fetch("https://serpcrypto.com/api/v1/search?" + params, {
  headers: { Authorization: "Bearer " + process.env.SERPCRYPTO_API_KEY },
});
const data = await res.json();
console.log(data.organic_results?.[0]?.link);
```

## มีค่า engine อะไรบ้าง และแต่ละค่าคืนอะไร?

โครงสร้าง (`search_metadata`, `search_parameters`, `search_information`) เหมือนกันทุก engine บล็อกจะปรากฏเฉพาะเมื่อหน้านั้นแสดงมัน

| `engine` | แหล่งที่มา | บล็อกหลักในคำตอบ |
| --- | --- | --- |
| `google` | ผลการค้นหา Google | `ai_overview`, `organic_results`, `ads`, `people_also_ask`, `local_results`, `knowledge_graph`, `top_stories`, `inline_videos`, `shopping_results`, `related_searches`, `pagination` |
| `google_news` | Google News | `news_results`: title, link, source, date, snippet, thumbnail |
| `google_images` | Google Images | `images_results`: URL ต้นฉบับและขนาด, thumbnail, หน้าแหล่งที่มา |
| `google_maps` | Google Maps | `local_results`: ชื่อ, ที่อยู่, โทรศัพท์, เว็บไซต์, คะแนน, รีวิว, หมวดหมู่, เวลาทำการ, พิกัด |
| `google_shopping` | Google Shopping | `shopping_results`: title, price, extracted price, currency, merchant, delivery, rating |
| `bing` | Bing | `organic_results`, `related_searches` |

## อ่านเครดิตของคุณ

`GET /api/v1/credits`

คืนค่าเครดิตที่เหลือในบัญชีของคุณ เครดิตที่ใช้ไปตั้งแต่เที่ยงคืน UTC และจำนวนการค้นหาที่บัญชีของคุณรันพร้อมกันได้ การเรียกนี้ฟรี ค่าด้านล่างเป็นตัวอย่าง

การยืนยันตัวตน: API key ใน header `Authorization: Bearer API_KEY`

**Response** `200`

```json
{
  "credits_remaining": 84210,
  "credits_used_today": 1290,
  "concurrency_limit": 10
}
```

*curl*

```bash
curl -s "https://serpcrypto.com/api/v1/credits" \
  -H "Authorization: Bearer $SERPCRYPTO_API_KEY"
```

*Python*

```python
import os

import requests

r = requests.get(
    "https://serpcrypto.com/api/v1/credits",
    headers={"Authorization": "Bearer " + os.environ["SERPCRYPTO_API_KEY"]},
    timeout=30,
)
r.raise_for_status()
print(r.json()["credits_remaining"])
```

*Node.js*

```javascript
const res = await fetch("https://serpcrypto.com/api/v1/credits", {
  headers: { Authorization: "Bearer " + process.env.SERPCRYPTO_API_KEY },
});
const { credits_remaining } = await res.json();
console.log(credits_remaining);
```

## API สามารถคืน error อะไรได้บ้าง?

ทุก error มี body เป็น `{"error": {"code": "…", "message": "…"}}` [หน้า errors](https://serpcrypto.com/th/docs/errors/) อธิบายแต่ละตัวและแสดง retry code

| HTTP | `code` | เมื่อเกิดขึ้น | เรียกเก็บ |
| --- | --- | --- | --- |
| 400 | `invalid_parameter` | พารามิเตอร์ที่จำเป็นหายไป หรือค่าอยู่นอกช่วงที่อนุญาต | ไม่ใช่ |
| 401 | `invalid_api_key` | API key หายไป ผิด หรือถูกเพิกถอน | ไม่ใช่ |
| 402 | `insufficient_credits` | บัญชีของคุณไม่มีเครดิตเหลือ | ไม่ใช่ |
| 429 | `concurrency_limit` | มีการค้นหามากเกินไปที่รันพร้อมกันในบัญชีของคุณ | ไม่ใช่ |
| 502 | `search_failed` | engine หรือการเก็บข้อมูลล้มเหลวสำหรับคำขอนี้ ลองใหม่ | ไม่ใช่ |
| 504 | `search_timeout` | ไม่มีการตอบกลับภายในเวลา ลองใหม่ | ไม่ใช่ |

## เรียกเก็บเงินอะไรกันแน่?

- **การค้นหาที่สำเร็จหนึ่งครั้ง = หนึ่งเครดิต** บนทุก engine รวมถึง Google Maps และ Google Shopping
- **ผลลัพธ์แต่ละหน้าเป็นการค้นหาหนึ่งครั้ง** ผลลัพธ์ออร์แกนิกประมาณ 10 รายการต่อหน้า ตามที่ Google ให้บริการตั้งแต่เลิกใช้ num=100 ในเดือนกันยายน 2025; แต่ละหน้าเพิ่มคือหนึ่งเครดิตเพิ่มเติม
- **error ฟรี:** ทุกคำตอบที่มี HTTP status อื่นที่ไม่ใช่ 200 ไม่ใช้เครดิต
- **การอ่านเครดิตของคุณฟรี**

เครดิตการค้นหาแบบเติมเงินไม่มีวันหมดอายุ: คำค้นหาที่ไม่ได้ใช้จะคงอยู่ในบัญชีของคุณจนกว่าคุณจะใช้ แพ็กมีตั้งแต่ US$7.50 สำหรับ 10,000 การค้นหา ไปจนถึง US$0.30/1K การค้นหา ในแพ็กที่ใหญ่ที่สุด ดู [ราคา](https://serpcrypto.com/th/pricing/)

## ฉันควร encode คำค้นหาอย่างไร?

ส่ง `q` แบบ URL-encoded เหมือนค่า query-string ทั่วไป: ช่องว่างกลายเป็น `%20` หรือ `+` และตัวอักษรที่มีวรรณยุกต์ถูก encode เป็น UTF-8 curl ทำเช่นนี้ด้วย `--data-urlencode`, Python `requests` และ `httpx` ทำด้วย `params=` ส่วน Node.js ทำด้วย `URLSearchParams`

เขียนคำค้นหาเหมือนที่คนพิมพ์ในช่องค้นหาจริง ๆ เครื่องหมายคำพูด เครื่องหมายลบ หรือ `site:` อยู่ใน `q` ตามเดิม engine เป็นผู้ตัดสินว่าจะใช้มันอย่างไร เช่นเดียวกับที่ทำกับผู้เข้าชม

## API มีเวอร์ชันหรือไม่?

มี เวอร์ชันเป็นส่วนหนึ่งของ path: `/api/v1/` ฟิลด์หรือบล็อกใหม่อาจปรากฏในคำตอบเวอร์ชัน 1 โค้ดของคุณจึงควรเพิกเฉยต่อคีย์ที่ไม่รู้จัก การลบหรือเปลี่ยนชื่อฟิลด์จะมาพร้อมเวอร์ชันใหม่ใน path ไม่ใช่การเปลี่ยนแปลงใน `v1`

## คำถามเกี่ยวกับ API reference

### ส่ง POST request พร้อม JSON body ได้ไหม

ไม่ได้ในเวอร์ชัน 1: ทั้งสอง endpoint รับ GET request โดยส่ง parameter ใน query string ซึ่งทำให้ทุกการเรียกทำซ้ำได้ง่ายด้วย curl หรือเบราว์เซอร์ และบันทึก log ได้ง่ายโดยไม่ต้องมี body

### การค้นหาหนึ่งครั้งคืนผลลัพธ์กี่รายการ

ผลลัพธ์ออร์แกนิกประมาณ 10 รายการต่อหน้า ตามที่ Google ให้บริการตั้งแต่เลิกใช้ num=100 ในเดือนกันยายน 2025; แต่ละหน้าเพิ่มคือหนึ่งเครดิตเพิ่มเติม หากต้องการเก็บ 30 ผลลัพธ์ ให้เรียก `page=1`, `page=2` และ `page=3`: สามครั้งค้นหา สามเครดิต

### เกิดอะไรขึ้นเมื่อเครดิตของฉันหมด

การค้นหาครั้งถัดไปจะคืน `402 insufficient_credits` และไม่ใช้เครดิตใดๆ ซื้อ pack อีกชุดจากยอดคงเหลือของคุณได้ที่ [หน้าราคา](https://serpcrypto.com/th/pricing/); API key ของคุณยังใช้งานได้และการค้นหากลับมาทำงานทันที

### ใช้ API key เดียวกันจากหลายเซิร์ฟเวอร์ได้ไหม

ได้ API key ไม่ผูกกับ IP address สิ่งที่จำกัดคือจำนวนการค้นหาที่ทำงานพร้อมกันในบัญชี: `concurrency_limit` ใน `GET /credits` ระบุตัวเลขไว้

---

SerpCrypto: SerpCrypto คือ SERP API สำหรับนักพัฒนาและ AI agent ที่ส่งคืนผลการค้นหา Google และ Bing เป็น JSON จ่ายด้วยคริปโตโดยไม่ต้องอัปโหลดบัตรประชาชน เครดิตการค้นหาแบบเติมเงินจาก US$0.30/1K การค้นหา ไม่มีวันหมดอายุ ไม่ต้อง KYC — ไม่ต้องใช้บัตรประชาชน ไม่ต้องเซลฟี่ ไม่ต้องใช้เอกสาร จ่ายด้วยคริปโต
