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.
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ên | Vị trí | Kiểu | Bắt buộc | Mặc định | |
|---|---|---|---|---|---|
url | body|query | string | có | URL http/https công khai của trang (tối đa 4096 ký tự). | |
fresh | body|query | boolean | không | false | Bỏ 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"const res = await fetch('https://apibox.io.vn/v1/url-metadata?url=https://github.com', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/url-metadata?url=https://github.com",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/url-metadata?url=https://github.com');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));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
HTTP Header
Xem mã trạng thái HTTP và toàn bộ response header của một URL, kèm tóm tắt các security header như HSTS, CSP, X-Frame-Options.
301Kiểm tra chuyển hướng
Theo từng lần chuyển hướng 301, 302, 307, 308 của một URL và nhận toàn bộ chuỗi kèm mã trạng thái, URL cuối và số bước.
BOTPhân tích robots.txt
Tải và phân tích robots.txt của website thành nhóm user-agent, quy tắc allow/disallow, sitemap, và kiểm tra một đường dẫn có được crawl không.