← Back to blog How to Extract Open Graph Data from Any URL — OGSnap API Tutorial
← All Posts
Tutorial OGSnap Open Graph

How to Extract Open Graph Data from Any URL

May 28, 2026 · 4 min read

You share a link. It shows up as a blank card — no title, no description, no image. That's because the platform couldn't find the Open Graph metadata.

OGSnap is a free API that extracts Open Graph tags, Twitter Cards, and JSON-LD structured data from any URL. It tells you exactly how a page will render when shared on social media — or what an AI agent can learn from it at a glance.

What is Open Graph Data?

Open Graph is a protocol that lets web pages declare how they should appear when shared on social platforms. Pages embed meta tags like:

<meta property="og:title" content="FetchAPI — API Suite for AI Agents">
<meta property="og:description" content="Simple HTTP APIs for AI agents">
<meta property="og:image" content="https://fetchapi.tech/og-image.png">

Twitter has its own variant (Twitter Cards), and many sites use JSON-LD for structured data. OGSnap extracts all three formats in one call.

Quick Start

curl "https://fetchapi.tech/v1/ogsnap?url=https://github.com/NousResearch/hermes-agent"

Response:

{
  "og": {
    "title": "NousResearch/hermes-agent",
    "description": "Hermes Agent is an open-source AI agent...",
    "image": "https://opengraph.githubassets.com/...",
    "url": "https://github.com/NousResearch/hermes-agent",
    "type": "object"
  },
  "twitter": {
    "card": "summary_large_image",
    "title": "NousResearch/hermes-agent",
    "description": "Hermes Agent is an open-source AI agent..."
  },
  "jsonld": [
    {
      "@context": "https://schema.org",
      "@type": "SoftwareSourceCode",
      "name": "Hermes Agent"
    }
  ]
}

Use Cases

1. Link Preview Generation

Build rich link previews for your app without a heavy headless browser:

// React component
function LinkPreview({ url }) {
  const [data, setData] = useState(null);

  useEffect(() => {
    fetch(`https://fetchapi.tech/v1/ogsnap?url=${encodeURIComponent(url)}`)
      .then(r => r.json())
      .then(setData);
  }, [url]);

  if (!data) return <div>Loading...</div>;

  return (
    <div className="link-preview">
      <img src={data.og.image} alt={data.og.title} />
      <h3>{data.og.title}</h3>
      <p>{data.og.description}</p>
    </div>
  );
}

2. Social Media Monitoring

Check how your competitors' pages render on social platforms:

curl "https://fetchapi.tech/v1/ogsnap?url=https://stripe.com/pricing"

See exactly what title, description, and image Stripe uses for social sharing.

3. SEO Auditing

Verify your own pages have correct OG tags:

for url in $(cat my-sitemap.txt); do
  og=$(curl -s "https://fetchapi.tech/v1/ogsnap?url=$url")
  title=$(echo "$og" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('og',{}).get('title','MISSING'))")
  echo "$url -> $title"
done

4. AI Agent Content Discovery

When your agent encounters a URL, OGSnap tells it what the page is about before scraping it. This lets it decide whether to read further:

@tool
def preview_url(url: str) -> str:
    \"\"\"Check what a URL contains before reading it.\"\"\"
    import requests
    resp = requests.get("https://fetchapi.tech/v1/ogsnap", params={"url": url})
    data = resp.json()
    title = data.get("og", {}).get("title", "No title")
    desc = data.get("og", {}).get("description", "No description")
    return f"{title}: {desc}"

What You Get

The response includes all three data types wherever they exist on the page:

If a page has none of these, the response returns empty objects — no errors, no crashes.

Integration Examples

Python

import requests

resp = requests.get("https://fetchapi.tech/v1/ogsnap", params={
    "url": "https://example.com/article"
})
data = resp.json()
print(data["og"]["title"])  # The page's OG title

JavaScript

const data = await fetch(
  "https://fetchapi.tech/v1/ogsnap?url=" + encodeURIComponent(url)
).then(r => r.json());

console.log(data.og.image);  // Open Graph image URL

Pricing

Free: 20 requests/day, no key needed
Pro: 5,000 requests/day, $12/mo
Enterprise: 50,000 requests/day, $49/mo

Try It Now

curl "https://fetchapi.tech/v1/ogsnap?url=https://news.ycombinator.com"

You'll see exactly how Hacker News presents itself when shared — no image, minimal OG tags, standard link format.


FetchAPI — API Suite for AI Agents