TRAP/OCR v0.4.1 API calls today avg latency 142ms uptime 99.97% ⚡ L402 rate $0.002/call self-hosted instances 847 QR decodes today platform resolvers 34 TRAP/OCR v0.4.1 API calls today avg latency 142ms uptime 99.97% ⚡ L402 rate $0.002/call self-hosted instances 847
Developer Platform

The TRAP runtime.
Open, hosted, or yours.

capsule-ocr is the open source OCR engine powering photrap.io. Self-host it, build on it, or call our hosted endpoint for $0.002 per request via L402 Lightning micropayment — no account, no API key, no billing dashboard.

↓ Download Source Use Hosted API See AI Integrations
MIT
capsule-ocr license
$0.002
per API call via L402
142ms
median latency
34
platform resolvers
Open Source
Download & self-host

The TRAP runtime and capsule-ocr are open source. Run them on your own hardware — homelab, VPS, or cloud. No telemetry, no call-home.

MIT License
capsule-ocr
Python · FastAPI v0.4.1 ~2MB
CPU-first OCR microservice with pluggable profiles (books, calendar, media). Powers the screenshot pipeline on photrap.io. Runs in Podman/Docker, no GPU required.
BSL 1.1
capsule-gateway
Go · 1.22 v0.3.0 ~800KB
The full Inbox/Shelf/SSE backend that photrap.io runs on. Self-hosting is free. Commercial use requires a license. Converts to Apache 2.0 in 2029.
BSL 1.1 — source visible, self-hosting permitted, commercial SaaS use requires a license from Dan Vaughn. contact@photrap.io for licensing inquiries. What is BSL?
Hosted API
Call it. Pay per use.
No account required.

Don't want to run infrastructure? Use our hosted endpoint. Every call is metered via L402 Lightning micropayments — pay exactly what you use, settle instantly, no signup.

Per-call rate
$0.002 USD / call
Paid via Lightning Network L402 protocol. Your client receives a 402 Payment Required with a Lightning invoice. Pay it, get a macaroon, call proceeds. No wallet lock-in — any Lightning wallet works.
⚡ L402 / Lightning
MethodEndpointDescriptionPrice
GET /v1/health Service health check free
POST /v1/ocr/suggest OCR image → text + ranked suggestions (title, author, provider, URL) $0.002
POST /v1/qr/decode Decode QR code from image → URL or payload $0.001
POST /v1/trap/resolve Resolve media URL → platform + resolver chain JSON $0.001
POST /v1/trap/full Full pipeline: image → QR/OCR → resolve → play link $0.004
Integration
Works with anything
that speaks HTTP.

curl, Python, JavaScript, or wire it directly into your AI agent. The L402 flow is handled by our client library or any standard Lightning wallet.

OCR + resolve in one call · Full pipeline
# Step 1: attempt call — receive L402 invoice
curl -X POST https://api.photrap.io/v1/trap/full \
  -F "file=@screenshot.png" \
  -w "%{http_code}"
# → 402 Payment Required
# → WWW-Authenticate: L402 macaroon="...", invoice="lnbc20..."

# Step 2: pay invoice with any Lightning wallet, get preimage
# Step 3: retry with credentials
curl -X POST https://api.photrap.io/v1/trap/full \
  -H "Authorization: L402 <macaroon>:<preimage>" \
  -F "file=@screenshot.png"
# → { "play_link": "https://photrap.io/p/ab3x9z2m",
#     "platform": "Spotify", "type": "track",
#     "resolver_chain": [...] }
Python · with trap-client library
from trap_client import TRAPClient

# Client handles L402 handshake automatically
# Uses your Lightning node or Alby wallet
client = TRAPClient(
    lightning_node="https://your-alby-or-lnd",
    budget_sats=100  # auto-pay up to 100 sats per session
)

# OCR a screenshot
result = client.ocr("screenshot.png", profile="books")
# → { text, suggestions: [{type, value, confidence}] }

# Full pipeline: image → play link
link = client.trap("now_playing.png")
# → "https://photrap.io/p/ab3x9z2m"

# Resolve a URL to platform info
chain = client.resolve("https://open.spotify.com/track/4iV5...")
# → { platform, type, resolver_chain, play_link }
JavaScript / Node.js
import { TRAPClient } from '@photrap/trap-client'

const client = new TRAPClient({
  wallet: 'https://api.getalby.com/payments',
  budgetSats: 50
})

// Screenshot → play link
const { playLink, platform, resolverChain } =
  await client.trap(imageBlob)

console.log(playLink)
// "https://photrap.io/p/ab3x9z2m"

// Or just OCR
const { text, suggestions } =
  await client.ocr(imageBlob, { profile: 'media' })

// Each call auto-handles L402:
// 402 received → pay invoice → retry with preimage
Claude / AI Agent — tool definition
// Give Claude (or any LLM) the TRAP endpoint as a tool
const tools = [{
  name: "trap_media",
  description: "Convert a media URL or image screenshot into a
    platform-agnostic play link that works across Spotify,
    YouTube, Plex, Apple Music, and 30+ other platforms.",
  input_schema: {
    type: "object",
    properties: {
      url:   { type: "string", description: "Media URL to resolve" },
      image: { type: "string", description: "Base64 image (screenshot/QR)" }
    }
  }
}]

// When Claude calls this tool, your handler:
async function trap_media({ url, image }) {
  return await client.trap(url || image)
  // Cost: ~$0.002 deducted from your L402 budget
  // Claude gets back the play link + resolver chain
}
AI Integrations
Projects built with
the TRAP runtime.

AI agents, home assistants, and media tools calling the TRAP API. Each call costs $0.002. Each solves a real problem.

🤖
Claude Media Agent
Give Claude a screenshot from any app — it calls TRAP, resolves the platform, and returns a play link your assistant can share or act on.
Claude Tool Use ⚡ L402
📚
Book Scanner → Shelf
Point your phone at any bookshelf. OCR extracts titles and authors with 90%+ accuracy. Results shelved directly into your capsule collection.
capsule-ocr · books profile
🎵
Shazam → Universal Link
Screenshot your now-playing screen. TRAP identifies the track and generates a link that opens in Spotify, Apple Music, Tidal, or YouTube Music — whatever the recipient has.
TRAP full pipeline ⚡ L402
🧾
QR → Anywhere
Concert ticket. Restaurant menu. Album QR code. Product tag. Decode any QR and resolve it to the best platform handler — without being locked into one app's scanner.
v1/qr/decode
🏠
Home Assistant Integration
HASS automation: when a new screenshot lands in a watched folder, TRAP processes it and pushes a play link to your media player. Zero manual steps.
Webhook · Self-hosted
Build your own
Any HTTP client, any language, any LLM. If you can pay a Lightning invoice and POST a file, you can build on TRAP. Start with the Python or JS client library.
See code samples →
Pricing
Three ways to use it.

Self-host for free. Pay per call. Or get a license for the full stack.

Self-host
Free forever
Run capsule-ocr on your own hardware. No limits, no telemetry, no check-in required.
  • capsule-ocr (MIT)
  • All OCR profiles
  • Unlimited calls
  • Podman / Docker
  • No SLA
  • You run it
GitHub →
Commercial License
Custom
License the capsule-gateway for commercial SaaS use. White-label, OEM, or enterprise deployment.
  • capsule-gateway (BSL→)
  • White-label rights
  • Priority support
  • SLA negotiable
  • Source access
  • Gov law: Missouri
Contact →