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:

  1. Send a GET or POST request to https://linkmeta.dev/api/v1/extract with the target URL as a query parameter or in the JSON body.
  2. Receive the JSON response containing openGraph, twitter, and general metadata fields.
  3. Access the extracted tags from data.openGraph.title, data.openGraph.image, and so on.
  4. Optionally filter fields using the fields parameter 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
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 — Filtered Fields
curl "https://linkmeta.dev/api/v1/extract?url=https://github.com&fields=openGraph,twitter"

The response will include only the requested fields:

JSON Response
{
  "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:

JavaScript
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:

Python
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:

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 — Batch Request
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 — Only OG Image & Title
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 — Custom Timeout
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 — Bypass Cache
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?
Open Graph is a protocol created by Facebook that controls how link previews appear on Facebook, LinkedIn, Slack, Discord, WhatsApp, and many other platforms. Twitter Cards are a separate meta tag system specifically for X (formerly Twitter). While both serve a similar purpose, Twitter Cards offer additional card types like 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?
No. The LinkMeta API is completely free and open. You do not need to create an account, generate an API key, or provide any form of authentication. Simply send an HTTP request to the extract endpoint with your target URL and receive structured metadata back immediately. This makes it ideal for quick prototypes, open-source projects, and production applications alike.
+ Can I extract Open Graph tags from URLs that require JavaScript rendering?
The LinkMeta API uses server-side HTTP requests to fetch the HTML of the target URL. Most websites include Open Graph tags in the initial HTML response, even for single-page applications (SPAs), because social media crawlers do not execute JavaScript. This means the API can extract OG tags from the vast majority of websites. For the rare cases where OG tags are injected client-side via JavaScript, the tags will not be available because no browser rendering occurs. However, this is a very uncommon pattern since it would also break Facebook, Twitter, and LinkedIn link previews.
+ What happens if a URL does not have Open Graph tags?
If the target URL does not include Open Graph meta tags, the 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?
The LinkMeta API typically returns results in under 200 milliseconds for most websites. The response includes a 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?
Yes. In addition to the extract endpoint, LinkMeta provides a dedicated validate endpoint at /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?
The API extracts a comprehensive set of metadata from any URL: page title, meta description, canonical URL, favicon, language, author, published date, modified date, keywords, theme color, word count, an auto-generated summary, the full redirect chain, Twitter Card data, Open Graph data, and JSON-LD structured data. You can also request opt-in fields like 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.