Extract Open Graph Tags from Any URL
Open Graph tags are HTML meta elements that control how your content appears when shared on social platforms like Facebook, LinkedIn, Slack, Discord, and messaging apps. Originally created by Facebook in 2010, the Open Graph protocol has become the universal standard for link previews across the web. When someone pastes a URL into a chat or social post, the platform reads these tags to generate a rich preview card with a title, description, and image.
Whether you are building a social media management tool, a content aggregator, a chat application with link previews, or an SEO auditing platform, you need a reliable way to extract Open Graph tags programmatically. The LinkMeta API lets you do exactly that with a single HTTP request, returning structured JSON with all OG tags, Twitter Card metadata, favicons, JSON-LD, and more. No API keys, no authentication, and completely free to use.
Understanding the Open Graph Protocol
The Open Graph protocol defines a set of meta tags placed in the <head> section of an HTML document. Each tag uses the property attribute with an og: prefix. Here are the core tags every page should have:
| Tag | Purpose | Example Value |
|---|---|---|
og:title |
The title of the page as it should appear in the link preview. Keep it under 60 characters for best display. | My Awesome Article |
og:description |
A brief summary of the content. Platforms typically truncate after 150-200 characters. | A deep dive into modern web APIs... |
og:image |
The URL of the image displayed in the preview card. Recommended size is 1200x630 pixels. | https://example.com/og.png |
og:url |
The canonical URL of the page. This is the URL that platforms associate with the shared content. | https://example.com/article |
og:type |
The type of content. Common values include website, article, product, and video.other. |
article |
og:site_name |
The name of the website or application. Displayed alongside the title on some platforms. | My Blog |
When you extract metadata from a URL using the LinkMeta API, all of these Open Graph properties are returned in a structured openGraph object within the JSON response, making it straightforward to access each value programmatically.
How to Extract Open Graph Tags with the LinkMeta API
The LinkMeta API provides a single endpoint that fetches a URL, parses its HTML, and returns all metadata in a clean JSON structure. Here is the step-by-step process:
- Send a GET or POST request to
https://linkmeta.dev/api/v1/extractwith the target URL as a query parameter or in the JSON body. - Receive the JSON response containing
openGraph,twitter, and general metadata fields. - Access the extracted tags from
data.openGraph.title,data.openGraph.image, and so on. - Optionally filter fields using the
fieldsparameter to request only the metadata you need, reducing response size.
No API key is required. No signup, no authentication, no usage limits. The API processes your request in real time, fetches the target URL, parses the HTML, and returns structured metadata in under 200 milliseconds for most pages.
Code Examples
cURL
The simplest way to test the API is with cURL from the command line. This fetches all metadata for a given URL, including the full Open Graph object:
curl "https://linkmeta.dev/api/v1/extract?url=https://github.com"
To request only the Open Graph and Twitter Card fields, use the fields parameter:
curl "https://linkmeta.dev/api/v1/extract?url=https://github.com&fields=openGraph,twitter"
The response will include only the requested fields:
{
"status": "success",
"cached": false,
"data": {
"openGraph": {
"title": "GitHub: Let's build from here",
"description": "GitHub is where over 100 million developers shape the future of software.",
"image": "https://github.githubassets.com/assets/campaign-social.png",
"url": "https://github.com/",
"type": "website",
"siteName": "GitHub",
"locale": "en_US"
},
"twitter": {
"card": "summary_large_image",
"site": "@github",
"creator": null,
"title": "GitHub: Let's build from here",
"description": "GitHub is where over 100 million developers shape the future of software.",
"image": "https://github.githubassets.com/assets/campaign-social.png"
}
}
}JavaScript (Fetch API)
In a browser or Node.js application, you can use the native fetch API. This example extracts OG tags and renders a link preview card:
async function extractOgTags(targetUrl) {
const apiUrl = `https://linkmeta.dev/api/v1/extract?url=${encodeURIComponent(targetUrl)}&fields=openGraph,twitter,title,image`;
const response = await fetch(apiUrl);
const { status, data } = await response.json();
if (status !== 'success') {
throw new Error('Failed to extract metadata');
}
console.log('OG Title:', data.openGraph?.title);
console.log('OG Image:', data.openGraph?.image);
console.log('OG Description:', data.openGraph?.description);
console.log('Twitter Card:', data.twitter?.card);
return data;
}
extractOgTags('https://github.com')
.then(data => console.log('Full metadata:', data))
.catch(err => console.error(err));Python (requests)
For Python applications, the requests library provides a clean interface. This example extracts and prints all available Open Graph tags:
import requests
def extract_og_tags(target_url: str) -> dict:
response = requests.get(
'https://linkmeta.dev/api/v1/extract',
params={
'url': target_url,
'fields': 'openGraph,twitter,title,image'
}
)
response.raise_for_status()
result = response.json()
if result['status'] != 'success':
raise Exception('Metadata extraction failed')
og = result['data'].get('openGraph', {})
print(f"Title: {og.get('title')}")
print(f"Description: {og.get('description')}")
print(f"Image: {og.get('image')}")
print(f"URL: {og.get('url')}")
print(f"Type: {og.get('type')}")
print(f"Site Name: {og.get('siteName')}")
return result['data']
metadata = extract_og_tags('https://github.com')
print(f"\nTwitter card type: {metadata.get('twitter', {}).get('card')}")Extracting Twitter Card Metadata
Twitter Cards are a separate set of meta tags (using the twitter: prefix) that control how content appears when shared on X (formerly Twitter). While Twitter will fall back to Open Graph tags if its own tags are missing, having dedicated Twitter Card tags gives you finer control over the preview.
The LinkMeta API extracts both Open Graph and Twitter Card metadata simultaneously. The twitter object in the response contains:
twitter:card— The card type:summary,summary_large_image,player, orapptwitter:title— The title for the card (falls back to og:title)twitter:description— The description text for the cardtwitter:image— The image URL for the card previewtwitter:site— The @username of the website (e.g. @github)twitter:creator— The @username of the content author
To extract only Twitter Card data, pass fields=twitter in your request. You can combine it with other fields like fields=openGraph,twitter to get both OG and Twitter metadata in one call.
Advanced Usage
Batch Extraction
If you need to extract Open Graph tags from multiple URLs at once, use the batch endpoint. You can submit up to 10 URLs in a single POST request, and the API will process them in parallel:
curl -X POST "https://linkmeta.dev/api/v1/batch" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"https://github.com",
"https://dev.to",
"https://stackoverflow.com"
],
"fields": "openGraph,twitter,title"
}'Field Filtering
By default, the API returns all available metadata fields. You can reduce response size by specifying exactly which fields you need. Available fields include: url, statusCode, contentType, title, description, image, favicon, openGraph, twitter, jsonLd, responseTime, and more.
curl "https://linkmeta.dev/api/v1/extract?url=https://dev.to&fields=openGraph"
Custom Timeout
Some websites respond slowly. You can increase the request timeout up to 30 seconds (30000 milliseconds) to handle these cases:
curl "https://linkmeta.dev/api/v1/extract?url=https://slow-site.example.com&timeout=20000"
Bypassing Cache
The API caches responses for performance. If you need fresh metadata (for example, after updating your OG tags), pass no_cache=true:
curl "https://linkmeta.dev/api/v1/extract?url=https://example.com&no_cache=true"
Frequently Asked Questions
+ What is the difference between Open Graph tags and Twitter Cards?
player for embedded video and app for app install buttons. If Twitter Card tags are missing, X will fall back to using Open Graph tags instead. The LinkMeta API extracts both in a single request, so you always get the complete picture.
+ Does the LinkMeta API require authentication or an API key?
+ Can I extract Open Graph tags from URLs that require JavaScript rendering?
+ What happens if a URL does not have Open Graph tags?
openGraph object in the response will contain null values for the missing fields. However, the API still extracts general metadata like the page title, description (from standard meta tags), favicon, and other available metadata. You can use these fallback values to build a link preview even when OG tags are absent.
+ How fast is the metadata extraction?
responseTime field so you can see exactly how long the extraction took. For subsequent requests to the same URL, cached responses are returned near-instantly. If a target site is slow to respond, you can increase the timeout up to 30 seconds using the timeout parameter. The default timeout is 10 seconds.
+ Can I validate whether my Open Graph tags are correctly implemented?
/api/v1/validate?url=.... It checks your Open Graph tags, Twitter Cards, and general SEO metadata, then returns a score (0-100), a letter grade (A-F), specific issues with severity levels, and per-platform readiness for Facebook, Twitter/X, and LinkedIn. This works as a free replacement for Facebook's Sharing Debugger.
+ What other metadata does LinkMeta extract besides Open Graph?
body (page text content) and favicons (all discovered favicons with sizes).
Looking for more? Read our guide on building a free URL metadata extraction API, or learn how to create link previews with our API. You can also try the interactive playground to test the API directly in your browser, or read the full API documentation for all available endpoints and parameters.