เอกสาร API

Rexiew API ช่วยให้คุณค้นหา อ่านรีวิว สร้างรีวิว AI ส่งรีวิวจากผู้ใช้ และฝังวิดเจ็ตรีวิวบนเว็บไซต์ใด ๆ ได้ การตอบสนองทั้งหมดเป็น JSON

URL ฐาน

https://rexiew.com/api

จุดปลายทางทั้งหมดสัมพันธ์กับ URL ฐานนี้

การตรวจสอบสิทธิ์

Public endpoints (reading reviews, searching, widgets) require no authentication. Endpoints that create or modify data require a JWT Bearer token.

To get a token, call POST /auth/login with your email and password. Include the token in subsequent requests:

Authorization: Bearer <access_token>

Access tokens expire after 1 hour. Use POST /auth/refresh with your refresh token to get a new one.

การจัดการข้อผิดพลาด

Errors return a JSON object with an error field and an appropriate HTTP status code.

{
  "error": "Invalid model_id"
}
CodeMeaning
400Bad request / validation error
401Unauthorized / invalid token
402Insufficient credits
403Forbidden / tier too low
404Resource not found
409Conflict (duplicate)
410Model retired
429Rate limit exceeded
502Upstream LLM error

จุดปลายทางสาธารณะ

ไม่จำเป็นต้องมีการยืนยันตัวตน

GET /health

ตรวจสอบว่า API ทำงานอยู่หรือไม่

การตอบสนอง

{
  "status": "ok",
  "service": "Rexiew API",
  "version": "1.0.0"
}
GET /models

แสดงรายการโมเดล LLM ทั้งหมดพร้อมข้อกำหนดเทียร์และสถานะที่ใช้งาน หากมีการยืนยันตัวตน จะรวมถึงว่าแต่ละโมเดลสามารถเข้าถึงได้สำหรับเทียร์สมาชิกของคุณหรือไม่

การตอบสนอง

{
  "models": [
    {
      "id": 19,
      "slug": "claude-opus-4-6",
      "name": "Claude Opus 4.6",
      "description": "The most powerful Claude LLM model.",
      "provider": "anthropic",
      "cost": 1,
      "active": true
    }
  ],
  "user_tier": "free"
}
GET /things/{id}

รับรายละเอียดของสิ่งของและรีวิวทั้งหมด

การตอบสนอง

{
  "thing": {
    "id": 42,
    "name": "iPhone 16 Pro",
    "type": "product",
    "review_count": 7,
    "avg_rating": 4.3,
    "created_at": "2025-06-01 12:00:00"
  },
  "reviews": [
    {
      "review_id": 101,
      "model_id": 19,
      "llm_name": "Claude Opus 4.6",
      "rating": 4.5,
      "review": "The iPhone 16 Pro represents...",
      "created_at": "2025-06-02 09:30:00"
    }
  ]
}
GET /review/{id}

รับรายละเอียดรีวิวแบบเต็มรวมถึงข้อดี ข้อเสีย ทางเลือก คะแนนตามมิติ และสถานะการยืนยันบนเชน

การตอบสนอง

{
  "review_id": 101,
  "thing_id": 42,
  "thing_name": "iPhone 16 Pro",
  "thing_type": "product",
  "model_id": 19,
  "llm_name": "Claude Opus 4.6",
  "reviewer_type": "ai",
  "review_aspect": "general",
  "rating": 4.5,
  "review": "The iPhone 16 Pro represents...",
  "pros": ["Excellent camera system", "Fast A18 chip"],
  "cons": ["High price", "Heavy"],
  "alternatives": [
    {"name": "Samsung Galaxy S25 Ultra", "difference": "More customizable with S Pen"}
  ],
  "dimensions": [
    {"slug": "build-quality", "label": "Build Quality", "score": 4.8}
  ],
  "blockinity_verified": false,
  "provifier_tx_digest": null,
  "created_at": "2025-06-02 09:30:00"
}
GET /review/{id}/verify

ยืนยันหลักฐานบนเชนของรีวิวจากผู้ใช้ที่ลงนาม ผ่าน Provifier

การตอบสนอง

{
  "verified": true,
  "tx_digest": "ABC123...",
  "chain": "sui",
  "data_hash": "sha256...",
  "explorer_url": "https://suiscan.xyz/mainnet/tx/ABC123..."
}

จุดปลายทางที่มีการตรวจสอบสิทธิ์

These endpoints require a JWT Bearer token in the Authorization header.

POST /auth/login

ตรวจสอบสิทธิ์ด้วยอีเมลและรหัสผ่าน ส่งคืน JWT access และ refresh tokens

เนื้อหาคำขอ

{
  "email": "user@example.com",
  "password": "yourpassword"
}

การตอบสนอง

{
  "access_token": "eyJ...",
  "refresh_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "user": {
    "id": 1,
    "email": "user@example.com",
    "role": "user",
    "credit_balance": 500
  }
}
POST /auth/register

สร้างบัญชีใหม่ รหัสผ่านต้องมีอย่างน้อย 10 ตัวอักษร

เนื้อหาคำขอ

{
  "email": "newuser@example.com",
  "password": "securepassword"
}

Response 201 Created

{
  "access_token": "eyJ...",
  "refresh_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "user": {
    "id": 2,
    "email": "newuser@example.com",
    "role": "user",
    "credit_balance": 0
  }
}
POST /auth/refresh

แลกเปลี่ยนโทเค็นรีเฟรชที่ถูกต้องเพื่อรับโทเค็นการเข้าถึงและรีเฟรชใหม่

เนื้อหาคำขอ

{
  "refresh_token": "eyJ..."
}

การตอบสนอง

{
  "access_token": "eyJ...",
  "refresh_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 3600
}
POST /review/resolve Auth

ขั้นตอนเบื้องต้นก่อนสร้างรีวิว ระบบจะแก้ไขข้อมูลนำเข้าของผู้ใช้เพื่อให้ตรงกับสิ่งที่มีอยู่ในฐานข้อมูล หรือแนะนำให้สร้างสิ่งใหม่ ใช้โมเดล AI ภายในเพื่อจับคู่

เนื้อหาคำขอ

{
  "thing_name": "iPhone 16 Pro",
  "thing_type": "product"
}

การตอบสนอง

{
  "resolved": {
    "match": true,
    "thing_id": 42,
    "thing_name": "iPhone 16 Pro",
    "thing_type": "product",
    "thing_slug": "iphone-16-pro",
    "review_count": 7,
    "avg_rating": 4.3
  },
  "candidates": [...],
  "suggestion": {
    "canonical_name": "iPhone 16 Pro",
    "thing_type": "product",
    "description": "Apple's premium smartphone...",
    "tags": ["smartphone", "apple", "premium"],
    "category": "smartphones"
  },
  "dimensions": [
    {"dimension_slug": "build-quality", "dimension_label": "Build Quality"}
  ],
  "aspects": [
    {"slug": "general", "label": "General", "review_count": 5},
    {"slug": "affiliate-program", "label": "Affiliate Program", "review_count": 2},
    {"slug": "pricing", "label": "Pricing", "review_count": 0}
  ],
  "cost_usd": 0.002,
  "elapsed_ms": 1200
}
POST /review/generate Auth

Generate an AI review for a thing. Costs 1 credit per review. Active models: Claude Opus 4.6 (ID 19) and GPT 5.4 (ID 25).

เนื้อหาคำขอ

{
  "thing_name": "iPhone 16 Pro",
  "thing_type": "product",
  "model_id": 19,
  "thing_id": 42,
  "thing_description": "Apple's premium smartphone"
}
FieldTypeRequiredDescription
thing_namestringYes*Name of the thing to review (max 255 chars)
thing_typestringNoproduct, service, place, brand, or other
model_idintYes19 (Opus 4.6) or 25 (GPT 5.4)
thing_idintNoIf provided, skips resolver and uses this thing directly
thing_descriptionstringNoDescription override for new things (max 255 chars)
review_aspectstringNoAspect to focus on (e.g. "affiliate-program", "pricing"). Defaults to "general"

* Required if thing_id is not provided.

Response 201 Created

{
  "review_id": 108,
  "thing_id": 42,
  "thing_name": "iPhone 16 Pro",
  "review_aspect": "general",
  "rating": 4.5,
  "review": "The iPhone 16 Pro represents...",
  "pros": ["Excellent camera", "Fast chip"],
  "cons": ["Expensive", "Heavy"],
  "alternatives": [
    {"name": "Samsung Galaxy S25 Ultra", "difference": "More customizable"}
  ],
  "llm_name": "Claude Opus 4.6",
  "llm_provider": "anthropic",
  "dimensions": [
    {"slug": "build-quality", "label": "Build Quality", "score": 4.8}
  ],
  "credits_spent": 1,
  "tokens": {"input_tokens": 850, "output_tokens": 620},
  "cost_usd": 0.059,
  "elapsed_ms": 8500
}
POST /review/human Auth

ส่งรีวิวที่เขียนโดยมนุษย์ จำกัดอัตราไว้ที่ 1 รายการต่อสิ่งของต่อผู้ใช้ต่อวัน ไม่บังคับให้รวมที่อยู่กระเป๋าสำหรับการตรวจสอบ Blockinity

เนื้อหาคำขอ

{
  "thing_id": 42,
  "rating_score": 4.5,
  "review_text": "I've used the iPhone 16 Pro for 3 months now...",
  "review_aspect": "general",
  "dimension_scores": {
    "build-quality": 4.8,
    "value-for-money": 3.5
  },
  "wallet_address": "0x..."
}

Response 201 Created

{
  "review_id": 109,
  "thing_id": 42,
  "thing_name": "iPhone 16 Pro",
  "reviewer_type": "human",
  "review_aspect": "general",
  "rating": 4.5,
  "review": "I've used the iPhone 16 Pro for 3 months now...",
  "dimensions": [
    {"slug": "build-quality", "label": "Build Quality", "score": 4.8}
  ],
  "blockinity_verified": true,
  "canonical_data": "{...}"
}
PATCH /review/{id}/sign Auth

แนบข้อมูลการลงนาม Provifier on-chain ไปยังบทวิจารณ์ของคุณ ทำให้บทวิจารณ์สามารถตรวจสอบได้ด้วยการเข้ารหัส

เนื้อหาคำขอ

{
  "tx_digest": "ABC123...",
  "data_hash": "sha256...",
  "chain": "sui"
}

การตอบสนอง

{
  "review_id": 109,
  "signed": true,
  "tx_digest": "ABC123...",
  "chain": "sui",
  "data_hash": "sha256..."
}
GET /review/history?page=1&limit=20 Auth

รับประวัติรีวิวของผู้ใช้ที่ผ่านการตรวจสอบสิทธิ์ในรูปแบบหน้า

พารามิเตอร์

ParamTypeDefaultDescription
pageint1Page number
limitint20Results per page (max 50)

การตอบสนอง

{
  "reviews": [...],
  "total": 45,
  "page": 1,
  "limit": 20,
  "pages": 3
}
GET /user/profile Auth

รับโปรไฟล์ยอดเงินเครดิต และข้อมูลการสมัครสมาชิกของผู้ใช้ที่ผ่านการตรวจสอบสิทธิ์

การตอบสนอง

{
  "user": {
    "id": 1,
    "email": "user@example.com",
    "role": "user",
    "credit_balance": 500,
    "member_since": "2025-01-15 10:00:00",
    "total_reviews": 23,
    "wallet_address": null
  }
}

Widget Endpoints

สาธารณะ ไม่ต้องมีการยืนยันตัวตน ข้อมูลการตอบสนองจะถูกแคชไว้เป็นเวลา 5 นาที ใช้เพื่อฝังข้อมูลรีวิว Rexiew บนเว็บไซต์ภายนอก

GET /widget/thing/{id}/badge

ข้อมูลแบตเจ็จเบา: คะแนนเฉลี่ยและจำนวนรีวิว เหมาะสำหรับการแสดงแบบอินไลน์

การตอบสนอง

{
  "thing_id": 42,
  "name": "iPhone 16 Pro",
  "avg_rating": 4.3,
  "review_count": 7,
  "branding": {
    "text": "Powered by Rexiew",
    "url": "https://rexiew.com/thing/iphone-16-pro",
    "logo": "https://rexiew.com/img/favicon/favicon-32x32.png"
  }
}
GET /widget/thing/{id}/summary

สรุปพร้อมข้อมูลรีวิว 3 อันดับแรกและคะแนนเฉลี่ยแต่ละด้าน เหมาะสำหรับวิดเจ็ตในแถบข้าง

การตอบสนอง

{
  "thing_id": 42,
  "name": "iPhone 16 Pro",
  "type": "product",
  "avg_rating": 4.3,
  "review_count": 7,
  "dimensions": [
    {"label": "Build Quality", "score": 4.8}
  ],
  "snippets": [
    {
      "review_id": 101,
      "llm_name": "Claude Opus 4.6",
      "rating": 4.5,
      "snippet": "The iPhone 16 Pro represents a significant...",
      "reviewer_type": "ai",
      "verified": false,
      "on_chain": false,
      "created_at": "2025-06-02 09:30:00"
    }
  ],
  "branding": {...}
}
GET /widget/thing/{id}

ข้อมูล payload วิดเจ็ตแบบเต็ม: การรีวิวทั้งหมดพร้อมข้อดี ข้อเสีย ทางเลือก มิติ บัตร และการตอบสนองของเจ้าของ

การตอบสนอง

{
  "thing_id": 42,
  "name": "iPhone 16 Pro",
  "type": "product",
  "website": "https://apple.com/iphone-16-pro",
  "avg_rating": 4.3,
  "review_count": 7,
  "dimensions": [...],
  "reviews": [
    {
      "review_id": 101,
      "model_id": 19,
      "llm_name": "Claude Opus 4.6",
      "rating": 4.5,
      "review": "...",
      "pros": ["..."],
      "cons": ["..."],
      "alternatives": [...],
      "reviewer_type": "ai",
      "badges": ["ai"],
      "dimensions": [
        {"label": "Build Quality", "score": 4.8}
      ],
      "created_at": "2025-06-02 09:30:00"
    }
  ],
  "branding": {...}
}
GET /widget/lookup?source={source}&external_id={id}

ค้นหาสิ่งของตามการอ้างอิงภายนอก มีประโยชน์สำหรับการบูรณาการที่แมป ID ของตนเองไปยัง Rexiew thing IDs

พารามิเตอร์

ParamTypeDescription
sourcestringIntegration source (e.g. "d1rectory")
external_idstringExternal ID in the source system

การตอบสนอง

{
  "thing_id": 42
}

คำแนะนำการฝัง Smartlink

เพิ่มการ์ดรีวิวที่สามารถชี้ได้ลงในเว็บไซต์ใดๆ ด้วยแท็กสคริปต์เดียวและแอตทริบิวต์ข้อมูล ไม่ต้องใช้คีย์ API

1. เพิ่มสคริปต์

Include the smartlink widget script on your page (ideally before </body>):

<script src="https://rexiew.com/widget/smartlink.js" defer></script>

2. มาร์กอัปลิงก์ของคุณ

Use data-rexiew (slug) or data-rexiew-q (name) on any element:

<!-- By slug (recommended, stable) -->
<a data-rexiew="iphone-16-pro">iPhone 16 Pro</a>

<!-- By name (flexible, fuzzy matching) -->
<a data-rexiew-q="Tesla Model 3">Tesla Model 3</a>

3. เสร็จแล้ว

สคริปต์จะค้นหาองค์ประกอบที่ทำเครื่องหมายไว้โดยอัตโนมัติ ดึงข้อมูลรีวิวจาก Rexiew API และแทนที่แต่ละลิงก์ด้วยเอกสิ่งเหน็บ เมื่อเลื่อนเมาส์ (บนเดสก์ทอป) หรือคลิก (บนอุปกรณ์เคลื่อนที่) จะมีการ์ดแสดงขึ้นมา:

  • ชื่อและประเภทของสิ่งที่รีวิว
  • คะแนนดาวและคะแนน
  • จำนวนรีวิว
  • คำอธิบาย
  • ตัวอย่างรีวิว AI ล่าสุด
  • ลิงก์ไปยังรีวิวฉบับเต็มบน Rexiew

ตัวอย่างที่สมบูรณ์

<!DOCTYPE html>
<html>
<body>
  <p>
    We compared the <a data-rexiew="iphone-16-pro">iPhone 16 Pro</a>
    against the <a data-rexiew-q="Samsung Galaxy S25 Ultra">Galaxy S25 Ultra</a>
    and found both to be excellent choices.
  </p>
  <script src="https://rexiew.com/widget/smartlink.js" defer></script>
</body>
</html>

การสนับสนุน SPA

For single-page apps that add content dynamically, call RexiewSmartlink.init() after inserting new elements:

// After dynamically adding data-rexiew elements
RexiewSmartlink.init();

ตัวอย่างการเริ่มต้นอย่างรวดเร็ว

สร้างรีวิว AI ครั้งแรกของคุณใน 3 API calls:

# 1. Login
curl -X POST https://rexiew.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"you@example.com","password":"yourpassword"}'

# 2. Resolve the thing (optional pre-step)
curl -X POST https://rexiew.com/api/review/resolve \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"thing_name":"iPhone 16 Pro","thing_type":"product"}'

# 3. Generate review with Claude Opus 4.6
curl -X POST https://rexiew.com/api/review/generate \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"thing_name":"iPhone 16 Pro","thing_type":"product","model_id":19}'