API Hop

เอกสาร

เอกสาร API Hop

ดึงผู้ใช้ตามชื่อผู้ใช้

>-

GEThttps://api.apihop.ai/v1/twitter/users

ใช้ username ค้นหาโปรไฟล์ผู้ใช้ เอนด์พอยต์นี้เหมาะเมื่อทราบเพียงชื่อผู้ใช้และต้องการ data.id มาตรฐานสำหรับคำขอไทม์ไลน์

text
GET https://api.apihop.ai/v1/twitter/users

การยืนยันตัวตน

เอนด์พอยต์ API Twitter ทั้งหมดต้องยืนยันตัวตนด้วย Bearer Token

http
Authorization: Bearer YOUR_API_KEY

พารามิเตอร์การค้นหา

usernamestringจำเป็น

ชื่อผู้ใช้ Twitter รับทั้ง elonmusk และ @elonmusk โดยเซิร์ฟเวอร์จะลบ @ นำหน้า

user.fieldsstring

ฟิลด์ผู้ใช้คั่นด้วยจุลภาค เช่น created_at,description,public_metrics,verified

ตัวอย่างคำขอ

bash
curl --request GET \
  "$API_BASE_URL/v1/twitter/users?username=elonmusk&user.fields=created_at,description,public_metrics,verified" \
  --header "Authorization: Bearer YOUR_API_KEY"

การตอบกลับ

dataobjectจำเป็น

ออบเจ็กต์ผู้ใช้ที่ปรับเป็นมาตรฐาน

ฟิลด์ data
idstringจำเป็น

ตัวระบุผู้ใช้ที่ไม่ซ้ำ ควรใช้ค่านี้สำหรับค้นหาไทม์ไลน์

namestringจำเป็น

ชื่อที่แสดง

usernamestringจำเป็น

ชื่อผู้ใช้โดยไม่มี @

created_atstring

เวลารูปแบบ ISO 8601 ส่งกลับเมื่อขอ user.fields=created_at

descriptionstring

ประวัติย่อผู้ใช้

entitiesobject

เอนทิตีโปรไฟล์ เช่น คำอธิบาย URL และลิงก์

locationstring

สถานที่ในโปรไฟล์ผู้ใช้

pinned_tweet_idstring

ID ทวีตที่ปักหมุด

profile_banner_urlstring

URL แบนเนอร์โปรไฟล์

profile_image_urlstring

URL ภาพโปรไฟล์

protectedboolean

บัญชีได้รับการป้องกันหรือไม่

public_metricsobject

ตัวชี้วัดสาธารณะของผู้ใช้

ฟิลด์ public_metrics
followers_countinteger

จำนวนผู้ติดตาม

following_countinteger

จำนวนบัญชีที่ติดตาม

tweet_countinteger

จำนวนทวีตทั้งหมด

listed_countinteger

จำนวนรายการที่มีผู้ใช้นี้ อาจไม่มีเมื่อแหล่งข้อมูลไม่ให้ค่า

urlstring

URL เว็บไซต์ในโปรไฟล์ผู้ใช้

verifiedboolean

บัญชีได้รับการยืนยันหรือไม่

verified_typestring

ประเภทการยืนยัน เช่น Business

ตัวอย่างสำเร็จ

json
{
  "data": {
    "id": "44196397",
    "name": "Elon Musk",
    "username": "elonmusk",
    "created_at": "2009-06-02T20:12:29.000Z",
    "description": "Mars and cars",
    "public_metrics": {
      "followers_count": 10,
      "following_count": 20,
      "tweet_count": 40
    },
    "verified": true
  }
}

การตอบกลับผิดพลาด

ดูรหัสข้อผิดพลาดและการแก้ปัญหา สำหรับรหัสทั้งหมด ความต่างของโปรโตคอล และขั้นตอนวินิจฉัย

json
{
  "success": false,
  "error": {
    "code": 40000,
    "message": "Insufficient credit. Required: 100000, Available: 99999"
  },
  "requestId": "req_xxx"
}

คำแนะนำการใช้งาน

  • หากทราบเพียง username ให้เรียกเอนด์พอยต์นี้ก่อน
  • หากจะค้นไทม์ไลน์ ให้ใช้ data.id ที่ส่งกลับ
  • หากต้องการเพียงรูปประจำตัว ประวัติย่อ หรือจำนวนผู้ติดตาม ให้ระบุ user.fields ชัดเจน