Express.js

Screenshot API for Express.js

Add screenshot endpoints to your Express server. Proxy screenshots or generate thumbnails on the fly.

Installation

npm install express

Express.js Integration Example

const express = require("express");
const app = express();

app.get("/screenshot", async (req, res) => {
  const url = req.query.url || "https://example.com";
  const response = await fetch(
    "https://snapapi.tech/v1/screenshot?" + new URLSearchParams({
      url, api_key: process.env.SNAPAPI_KEY, format: "png"
    })
  );
  res.set("Content-Type", "image/png");
  res.send(Buffer.from(await response.arrayBuffer()));
});


// POST /api/bp/manual-unlock — admin triggers full report delivery without LemonSqueezy payment
app.post("/api/bp/manual-unlock", express.json(), requireAnthropicCredits, async (req, res) => {
  const key = req.headers["x-admin-key"];
  if (!key || key !== (process.env.ADMIN_KEY || "bp-admin-2026")) return res.status(401).json({ error: "Unauthorized" });
  const { lead_id } = req.body || {};
  if (!lead_id) return res.status(400).json({ error: "lead_id required" });
  try {
    const { rows } = await pool.query("SELECT * FROM bp_locked_reports WHERE id=$1 LIMIT 1", [lead_id]);
    if (!rows.length) return res.status(404).json({ error: "Lead not found" });
    const lead = rows[0];
    await resend.emails.send({
      from: "BusinessPulse <support@snapapi.tech>",
      to: [lead.lead_email],
      subject: "Your BusinessPulse Report is Unlocked — " + lead.company + " Competitive Intelligence",
      html: lead.full_report_html,
    });
    await pool.query("UPDATE bp_locked_reports SET unlocked_at=NOW(), payment_id=$1 WHERE id=$2", ["manual-unlock", lead_id]);
    res.json({ ok: true, lead_id, email: lead.lead_email });
  } catch(e) { res.status(500).json({ error: e.message }); }
});
app.listen(3000);

Features

SnapAPI renders pages in a real Chromium browser, so JavaScript-heavy Express.js apps render perfectly. You get:

Get Free API KeyFull API Docs