🔗 Use Case

Link Preview API

Generate rich link previews like Slack, Discord, and Twitter. Show users what they'll find before they click.

The Problem with Traditional Link Previews

When building a chat app, social platform, or content management system, you want to show rich previews when users share links. The traditional approach relies on Open Graph (OG) meta tags, but:

The Solution: Screenshot-Based Previews

Instead of relying on OG tags, capture a real screenshot of the website. This guarantees:

Implementation Example

API Endpoint for Link Previews

// Express.js endpoint
app.get('/api/link-preview', async (req, res) => {
    const { url } = req.query;
    
    // Optimal dimensions for social cards
    const params = new URLSearchParams({
        url: url,
        api_key: process.env.SNAPAPI_KEY,
        width: '1200',
        height: '630',
        response: 'binary'
    });
    
    const response = await fetch(
        `https://snapapi.alterra-solutions.com/v1/screenshot?${params}`
    );
    
    // Cache for 24 hours
    res.set('Cache-Control', 'public, max-age=86400');
    res.set('Content-Type', 'image/png');
    res.send(Buffer.from(await response.arrayBuffer()));
});

Frontend Usage

<!-- In your chat message or card component -->
<div class="link-preview">
    <img 
        src="/api/link-preview?url=https://github.com" 
        alt="Link preview"
        loading="lazy"
    />
    <div class="link-info">
        <h4>GitHub</h4>
        <p>github.com</p>
    </div>
</div>

Why Choose SnapAPI for Link Previews?

⚡

Fast Response

Under 2 seconds for most URLs. Perfect for real-time chat apps.

💾

Easy Caching

Cache responses at your CDN layer for instant repeat requests.

📐

Social Card Ready

1200×630 dimensions perfect for Twitter, LinkedIn, Facebook.

💰

100 Free/Month

Start free, scale as you grow. Predictable pricing.

Build Better Link Previews

Start with 100 free screenshots per month. No credit card required.

Get Free API Key →