Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Link Preview & Open Graph Scraper

Paste a link into Slack, WhatsApp or Twitter and a tidy preview card appears — title, description, image. Try to build that yourself and it falls apart fast: you write a scraper, and then discover redirects, gzip and brotli encoding, HTML entities, relative image paths, pages with no Open Graph tags at all, and sites that block datacenter IPs outright. What started as "just parse two meta tags" becomes a maintenance burden that breaks on the exact URLs your users care about.

This API collapses all of that into a single GET request. Call /preview?url=... and get back a clean JSON object with the page title, description, Open Graph and Twitter card tags, favicon, canonical URL and the best preview image — with relative URLs already resolved to absolute ones. It follows redirects, decodes entities, applies a smart fallback chain (Open Graph → Twitter card → plain HTML) and can route through residential proxies when a site blocks cloud traffic.

Use it for:

  • Chat apps and comment sections — unfurl pasted links into cards, like Slack or Discord
  • CMS and newsletter tooling — auto-generate link embeds from a URL
  • Bookmarking and read-it-later tools — store title, image and description alongside every saved link
  • Social feeds — render consistent preview cards even for pages with messy or missing metadata

Batch up to 10 URLs per call with /batch, or validate URLs for free with /validate.

Get started

  1. Subscribe (free tier available) on RapidAPI and copy your X-RapidAPI-Key.
  2. Call the API — here's the primary endpoint in every major language.

Base URL: https://link-preview-open-graph-scraper.p.rapidapi.com

Code examples

cURL

curl --request GET \
  --url 'https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F' \
  --header 'X-RapidAPI-Key: YOUR_RAPIDAPI_KEY' \
  --header 'X-RapidAPI-Host: link-preview-open-graph-scraper.p.rapidapi.com'

Python

import requests

url = "https://link-preview-open-graph-scraper.p.rapidapi.com/preview"
querystring = {"url": "https://www.wikipedia.org/"}
headers = {
    "X-RapidAPI-Key": "YOUR_RAPIDAPI_KEY",
    "X-RapidAPI-Host": "link-preview-open-graph-scraper.p.rapidapi.com",
}

response = requests.get(url, headers=headers, params=querystring)
print(response.json())

JavaScript (fetch)

const url = 'https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F';
const options = {
  method: 'GET',
  headers: {
    'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host': 'link-preview-open-graph-scraper.p.rapidapi.com',
  },
};

const response = await fetch(url, options);
console.log(await response.json());

Node.js (axios)

import axios from 'axios';

const options = {
  method: 'GET',
  url: 'https://link-preview-open-graph-scraper.p.rapidapi.com/preview',
  params: {url: 'https://www.wikipedia.org/'},
  headers: {
    'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host': 'link-preview-open-graph-scraper.p.rapidapi.com',
  },
};

const { data } = await axios.request(options);
console.log(data);

TypeScript

const url = 'https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F';

const response = await fetch(url, {
  method: 'GET',
  headers: {
    'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host': 'link-preview-open-graph-scraper.p.rapidapi.com',
  } as Record<string, string>,
});

const data: unknown = await response.json();
console.log(data);

PHP

<?php
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY",
        "X-RapidAPI-Host: link-preview-open-graph-scraper.p.rapidapi.com",
    ],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Ruby

require 'uri'
require 'net/http'

url = URI("https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["X-RapidAPI-Key"] = 'YOUR_RAPIDAPI_KEY'
request["X-RapidAPI-Host"] = 'link-preview-open-graph-scraper.p.rapidapi.com'

response = http.request(request)
puts response.read_body

Java (OkHttp)

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
    .url("https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F")
    .get()
    .addHeader("X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY")
    .addHeader("X-RapidAPI-Host", "link-preview-open-graph-scraper.p.rapidapi.com")
    .build();

Response response = client.newCall(request).execute();
System.out.println(response.body().string());

C#

using var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri("https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F"),
    Headers =
    {
        { "X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY" },
        { "X-RapidAPI-Host", "link-preview-open-graph-scraper.p.rapidapi.com" },
    },
};

using var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Go

package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F", nil)
    req.Header.Add("X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY")
    req.Header.Add("X-RapidAPI-Host", "link-preview-open-graph-scraper.p.rapidapi.com")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}

Rust

use reqwest::header::{HeaderMap, HeaderValue};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("X-RapidAPI-Key", HeaderValue::from_static("YOUR_RAPIDAPI_KEY"));
    headers.insert("X-RapidAPI-Host", HeaderValue::from_static("link-preview-open-graph-scraper.p.rapidapi.com"));

    let client = reqwest::Client::new();
    let res = client.get("https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F").headers(headers).send().await?;
    println!("{}", res.text().await?);
    Ok(())
}

Swift

import Foundation

var request = URLRequest(url: URL(string: "https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F")!)
request.httpMethod = "GET"
request.setValue("YOUR_RAPIDAPI_KEY", forHTTPHeaderField: "X-RapidAPI-Key")
request.setValue("link-preview-open-graph-scraper.p.rapidapi.com", forHTTPHeaderField: "X-RapidAPI-Host")

let (data, _) = try await URLSession.shared.data(for: request)
print(String(data: data, encoding: .utf8)!)

Kotlin

val client = OkHttpClient()

val request = Request.Builder()
    .url("https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F")
    .get()
    .addHeader("X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY")
    .addHeader("X-RapidAPI-Host", "link-preview-open-graph-scraper.p.rapidapi.com")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())

Shell (wget)

wget -qO- \
  --header='X-RapidAPI-Key: YOUR_RAPIDAPI_KEY' \
  --header='X-RapidAPI-Host: link-preview-open-graph-scraper.p.rapidapi.com' \
  'https://link-preview-open-graph-scraper.p.rapidapi.com/preview?url=https%3A%2F%2Fwww.wikipedia.org%2F'

Endpoints

Method Path Description
GET /preview Get a ready-to-render link preview for a URL
GET /og Extract only the Open Graph tags from a URL
GET /twitter Extract only the Twitter card tags from a URL
GET /metadata Get every raw meta and link tag from a URL
GET /validate Validate and dissect a URL without fetching it
POST /batch Preview up to 10 URLs in a single request

How to build Slack-style link previews from any URL with one GET request

Read the full guide: How to build Slack-style link previews from any URL with one GET request


⭐ Powered by the Link Preview & Open Graph Scraper API on RapidAPI.

About

Turn any URL into a rich link preview with one GET request: title, description, Open Graph and Twitter tags, best image, favicon — plus batch and validation.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors