Metadata của URL API

Lấy tiêu đề, mô tả, thẻ Open Graph, Twitter Card, favicon, canonical, RSS và JSON-LD của bất kỳ URL nào dưới dạng JSON.

GETPOSThttps://apibox.io.vn/v1/url-metadata

Truyền một url công khai, API sẽ tải trang (tự theo chuyển hướng) và phân tích phần <head>: tiêu đề, mô tả, ảnh xem trước và alt, tên site, loại, locale, ngôn ngữ, URL canonical, tác giả, từ khoá, thời gian xuất bản, theme color và chỉ thị robots. Giá trị được lấy lần lượt từ Open Graph, Twitter Card rồi đến meta tag thường; URL ảnh và icon được chuyển thành đường dẫn tuyệt đối.

Kết quả còn có toàn bộ thẻ open_graph, twitter_card và các meta khác, danh sách icons (icon đầu tiên là favicon, nếu không có thì dùng /favicon.ico), feeds RSS/Atom, alternates (link hreflang), tối đa 5 khối json_ld, cùng URL cuối, mã HTTP, content type, chuỗi chuyển hướng và thời gian phản hồi. Với URL không phải HTML chỉ trả về các trường cơ bản.

Kết quả được cache 1 giờ cho mỗi URL; thêm fresh=true để bỏ qua cache. Trang được đọc tối đa 1,5 MB, timeout 10 giây, tối đa 8 lần chuyển hướng. Chỉ chấp nhận host http/https công khai.

Tham số

TênVị tríKiểuBắt buộcMặc định
urlbody|querystringcóURL http/https công khai của trang (tối đa 4096 ký tự).
freshbody|querybooleankhôngfalseBỏ qua cache 1 giờ và tải lại trang.

Ví dụ

curl "https://apibox.io.vn/v1/url-metadata?url=https://github.com" \
  -H "Authorization: Bearer YOUR_API_KEY"

Kết quả trả về

{
  "url": "https://github.com/",
  "final_url": "https://github.com/",
  "status": 200,
  "content_type": "text/html; charset=utf-8",
  "redirects": [],
  "response_ms": 461,
  "title": "GitHub · Change is constant. GitHub keeps you ahead. · GitHub",
  "description": "Join the world's most widely adopted, AI-powered developer platform where millions of developers, businesses, and the largest open source community build software that advances humanity.",
  "image": "https://images.ctfassets.net/8aevphvgewt8/76epZKB2wF998m4e4bLLXn/c505f20b00ec70b88b1be5aec42c4be4/OG_image.jpg",
  "image_alt": "Join the world's most widely adopted, AI-powered developer platform where millions of developers, businesses, and the largest open source community build software that advances humanity.",
  "site_name": "GitHub",
  "type": "object",
  "locale": null,
  "lang": "en",
  "canonical": "https://github.com/",
  "author": null,
  "keywords": [],
  "published_time": null,
  "theme_color": "#1e2327",
  "robots": null,
  "favicon": "https://github.githubassets.com/favicons/favicon.png",
  "icons": [
    {
      "href": "https://github.githubassets.com/favicons/favicon.png",
      "rel": "alternate icon",
      "type": "image/png"
    },
    {
      "href": "https://github.githubassets.com/favicons/favicon.svg",
      "rel": "icon",
      "type": "image/svg+xml"
    }
  ],
  "feeds": [],
  "alternates": [
    "https://github.com/",
    "https://github.com/?locale=pt-br",
    "https://github.com/?locale=ja"
  ],
  "open_graph": {
    "image": "https://images.ctfassets.net/8aevphvgewt8/76epZKB2wF998m4e4bLLXn/c505f20b00ec70b88b1be5aec42c4be4/OG_image.jpg",
    "site_name": "GitHub",
    "type": "object",
    "title": "GitHub · Change is constant. GitHub keeps you ahead. · GitHub",
    "url": "https://github.com/",
    "description": "Join the world's most widely adopted, AI-powered developer platform..."
  },
  "twitter_card": {
    "site": "@github",
    "card": "summary_large_image",
    "title": "GitHub · Change is constant. GitHub keeps you ahead. · GitHub"
  },
  "meta": {
    "viewport": "width=device-width",
    "description": "Join the world's most widely adopted, AI-powered developer platform..."
  },
  "json_ld": []
}

Ứng dụng

  • Tạo link preview (thẻ xem trước) cho ứng dụng chat, CMS, mạng xã hội
  • Kiểm tra thẻ Open Graph và Twitter Card trước khi chia sẻ trang
  • Thu thập tiêu đề, favicon và mô tả cho trình quản lý bookmark
  • Tìm RSS feed và dữ liệu có cấu trúc (JSON-LD) của một website

Hỏi đáp

Làm sao lấy ảnh Open Graph của một URL?

Gọi /v1/url-metadata?url=... rồi đọc trường image (og:image, nếu không có thì twitter:image) hoặc toàn bộ object open_graph.

Kết quả có được cache không?

Có, 1 giờ cho mỗi URL. Thêm fresh=true để tải lại trang, ví dụ ngay sau khi bạn sửa meta tag.

API có theo chuyển hướng không?

Có, tối đa 8 lần. Kết quả có final_url và chuỗi redirects kèm mã trạng thái từng bước.

API liên quan

Bắt đầu với 1.000 request miễn phí mỗi tháng. Nhận API key miễn phí →