DEV Community

Weerasak Chongnguluam
Weerasak Chongnguluam

Posted on

4

ใช้ Dev.to API ถึงข้อมูลของบทความที่เขียนออกมา

เว็บ Dev.to ที่เขียนอยู่นี้มี API ให้ใช้ด้วย ตัวอย่างเช่นถ้าเราอยากลิสต์บทความของ user คนไหนออกมาดูก็เรียก http GET ที่ endpoint นี้ แล้วใส่ query string username กับกำหนดชื่อ username ที่ต้องการลิสต์บทความ

https://dev.to/api/articles?username=iporsut
Enter fullscreen mode Exit fullscreen mode

Alt Text

ซึ่งปกติจะได้ 30 บทความล่าสุด แต่ตัว API support pagination ด้วยก็ใส่ option ดึง page ต่อไปมาได้

ทีนี้ถ้าอยากดูข้อมูลเฉพาะของบทความใดๆ ก็เรียก GET ไปที่ endpoint เดิม แต่ใส่ path param เป็น ID ของบทความที่ต้องการ แบบนี้

https://dev.to/api/articles/719722
Enter fullscreen mode Exit fullscreen mode

ซึ่งก็จะมีข้อมูลของบทความหมายเลข 719722 ออกมาซึ่งรวมทั้ง HTML ของหน้าบทความนี้ด้วย

Alt Text

นอกจากนั้นยังมี API อื่นๆอีกลองเราไปดูได้ที่นี่ครับ https://docs.forem.com/api/

มีประโยชน์มากๆเพราะเราสามารถเขียนบทความที่ dev.to แล้วไปสร้าง page ของเราเองที่ดึงข้อมูลจาก dev.to ไปแสดงเพื่อ custom การแสดงผลเองได้ด้วย

ขอฝาก Buy Me a Coffee

สำหรับท่านใดที่อ่านแล้วชอบโพสต์ต่างๆของผมที่นี่ ต้องการสนับสนุนค่ากาแฟเล็กๆน้อยๆ สามารถสนับสนุนผมได้ผ่านทาง Buy Me a Coffee คลิ๊กที่รูปด้านล่างนี้ได้เลยครับ

Buy Me A Coffee

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more