8 Integration Templates

Copy. Paste. Ship.

Working code examples for Node.js, Python, Next.js, Shopify, AWS Lambda, and GitHub Actions. One POST call. Clean images. Full compliance.

Browse examples Live API demo

Install the SDK

Pick your language. Paste the command. Start integrating in under a minute.

$ npm install @polsia/filtrate
$ yarn add @polsia/filtrate
$ pnpm add @polsia/filtrate
$ pip install filtrate
$ pip install filtrate[async] # with asyncio support
$ poetry add filtrate
$ curl -X POST https://filtrate.polsia.app/v1/process \\\\
-H "Authorization: Bearer $FILTRATE_API_KEY" \\\\
-F "image=@product.jpg"

One call. Everything.

EXIF strip, WebP compression, and AI content moderation — all in a single request. 1–5 second response. $0.002/image.

"image": File/URL // multipart form field "quality": 85 // WebP quality 1-100 (optional) // Response: { "status": "safe", // safe | explicit | fraud | banned_logo "optimized_url": "https://cdn.filtrate...", "size_reduction": "67%", "processing_ms": 1842, "compliance": { "verdict": "safe", "categories": { "explicit": { "flagged": false }, "fraud": { "flagged": false }, "banned_logo": { "flagged": false } } } }
node.js Node.js
const { Filtrate } = require('@polsia/filtrate');
const filtrate = new Filtrate({ apiKey: process.env.FILTRATE_API_KEY });

// Process an image — returns optimized URL + compliance verdict
const result = await filtrate.process({
  image: fs.createReadStream('product.jpg'),
  // image: 'https://example.com/product.jpg', // URL also works
  quality: 85,
});

if (result.status !== 'safe') {
  console.log('Blocked:', result.status);
  return res.status(422).json({ blocked: true });
}

console.log('Clean! CDN URL:', result.optimized_url);
console.log('Size reduced by', result.size_reduction);
python.py Python
from filtrate import Filtrate

client = Filtrate(api_key=os.environ["FILTRATE_API_KEY"])

result = client.process(
    image_path="product.jpg",  # or image_url=...
    quality=85,
)

if result["status"] != "safe":
    raise ValueError(f"Image blocked: {result['status']}")

print(f"Clean! {result['optimized_url']}")
print(f"Reduced by {result['size_reduction']}")

Try it. Right now.

Paste a URL or use one of the sample images. No account needed.

REQUEST 5 free / 15min
RESPONSE
Your result will appear here

Pick your stack. Ship in minutes.

All examples are working, production-ready code. Copy the snippet, read the README, deploy.

🖼
Next.js Marketplace
Featured ★ 220+

Full marketplace app — drag-and-drop seller upload, AI compliance verdict, listing pages, and admin moderation log. Complete, runnable, deploys to Vercel in 60 seconds.

// App Router server component
import { processImage } from "@/lib/filtrate";

export async function POST(req) {
  const { imageUrl } = await req.json();
  const result = await processImage(imageUrl, {
    apiKey: process.env.FILTRATE_API_KEY,
  });
  if (result.verdict !== "safe") {
    return Response.json({ error: "Image flagged" }, { status: 422 });
  }
  return Response.json({ url: result.optimized_url });
}
Next.js 14 App Router SQLite React Dropzone
🖼
Express Middleware
Low complexity

Drop-in Express middleware (`filtrate-guard`) that intercepts multer uploads, scans with Filtrate, and attaches the verdict to `req.filtrate` before your storage handler runs.

app.post('/products/:id/photo',
  upload.single('image'),   // 1. Parse multipart
  filtrateGuard(),          // 2. Scan with Filtrate — blocks unsafe
  async (req, res) => {
    // 3. Image is safe — use req.filtrate.optimized_url
    await s3.upload({ Body: req.file.buffer }).promise();
    res.json({ url: req.filtrate.optimized_url });
  }
);
Express Multer Node.js
🖼
Shopify Webhook

Handles `products/create` and `products/update` Shopify webhooks. HMAC-verified. Scans all product images in parallel and tags flagged listings via the Admin API. Includes ngrok for local testing.

app.post('/webhooks/shopify/products', async (req, res) => {
  const { admin, topic } = req.body;

  if (topic !== 'products/create' && topic !== 'products/update') {
    return res.sendStatus(200);
  }

  const images = await getProductImages(admin, req.body.id);
  const results = await Promise.all(
    images.map(url => filtrate.process(url))
  );

  const flagged = results.filter(r => r.verdict !== 'safe');
  if (flagged.length) {
    await admin.tagProduct(req.body.id, 'needs-review');
  }

  res.sendStatus(200);
});
Express Node.js Shopify Admin API
🖼
Async Batch + Webhooks

Submits a batch of images to the async `/v1/batch` endpoint, then listens for the HMAC-signed webhook callback when processing completes. Full signature verification included.

// Submit batch
const { batch_id } = await fetch('https://filtrate.polsia.app/v1/batch', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.FILTRATE_API_KEY}` },
  body: JSON.stringify({ image_urls, callback_url: `https://my.app/webhooks/filtrate` }),
}).then(r => r.json());

// Listen for webhook
app.post('/webhooks/filtrate', (req, res) => {
  const sig = verifyHmac(req.rawBody, req.headers['x-filtrate-signature']);
  if (!sig.valid) return res.sendStatus(401);

  const { batch_id, status, succeeded } = sig.payload;
  // Fetch results from sig.payload.results_url
  res.sendStatus(200);
});
Express Node.js HMAC Webhooks
🖼
AWS Lambda + S3

S3-triggered Lambda scanner. On `ObjectCreated` events under `incoming/`, it scans with Filtrate, moves clean files to `clean/` and quarantines violations under `quarantine/` with metadata tags.

// S3 trigger handler
exports.handler = async (event) => {
  const key = event.Records[0].s3.object.key;

  const result = await filtrate.processFromS3(bucket, key);

  if (result.verdict === 'safe') {
    await s3.copyObject({
      CopySource: `${bucket}/${key}`,
      Key: key.replace('incoming/', 'clean/'),
    });
  } else {
    await s3.copyObject({
      CopySource: `${bucket}/${key}`,
      Key: `quarantine/${key}`,
      Metadata: { filtrate_verdict: result.verdict },
    });
  }
};
AWS Lambda SAM S3 Node.js
🖼
React + Dropzone

Self-contained React + TypeScript dropzone component with verdict badges, progress indicator, and optimized image preview. Zero external runtime deps. Works with any backend.

import { FiltrateDropzone } from './FiltrateDropzone';

export default function ProductPage() {
  return (
    <FiltrateDropzone
      apiEndpoint="/api/upload"
      apiKey={process.env.NEXT_PUBLIC_FILTRATE_KEY}
      onSuccess={(result) => {
        setImageUrl(result.optimized_url);
        setVerdict(result.verdict);
      }}
    />
  );
}
React TypeScript Dropzone UI
🖼
Next.js Upload Route

Next.js 14 App Router upload route. Accepts multipart uploads via drag-and-drop, forwards to Filtrate, returns the optimized WebP URL. Returns `422` on compliance violations.

// app/api/upload/route.ts
import { NextRequest } from 'next/server';

export async function POST(req: NextRequest) {
  const form = await req.formData();
  const file = form.get('image') as File;

  const result = await fetch('https://filtrate.polsia.app/v1/process', {
    method: 'POST',
    headers: { Authorization: `Bearer ${process.env.FILTRATE_API_KEY}` },
    body: file,
  }).then(r => r.json());

  if (result.status !== 'safe') {
    return Response.json({ error: result.status }, { status: 422 });
  }

  return Response.json({ url: result.optimized_url });
}
Next.js 14 App Router TypeScript
🖼
GitHub Action
DevOps

GitHub Action that scans all images in a PR — checks EXIF metadata, GPS, and compression quality. Posts a comment with a compliance report and fails the check on violations.

name: Filtrate Image Privacy Scan
on: [pull_request]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: Polsia-Inc/filtrate-action@v1
        with:
          api_key: ${{ secrets.FILTRATE_API_KEY }}
          paths: "images/** public/**"
GitHub Actions YAML PR Checks

Get your free API key.

No credit card. No signup form. Just a key, ready in 30 seconds.

Get API Key — free Read the docs

$0.002 / image

Pay-as-you-go. No monthly minimum. Volume discounts at 100K+.

1–5 second response

EXIF strip + WebP compress + AI moderation in a single call.

Batch + webhooks

Process thousands of images async with webhook callbacks.