Skip to content

API Reference

API Reference

The bloqr-backend exposes two complementary APIs:

  1. REST/HTTP API — JSON endpoints for compilation, configuration, queue management, monitoring, and administration.
  2. TypeScript Library API — JSDoc-annotated classes and functions for direct library usage (Deno / Node.js).

Authentication

All write endpoints require authentication. Three methods are supported:

MethodHeaderDescription
Better Auth sessionAuthorization: Bearer <session-token>Cookie or bearer session token. Created on sign-up/sign-in via /api/auth/sign-in/email.
API KeyAuthorization: Bearer abc_<key>Long-lived programmatic access key (abc_ prefix). Created via the API keys dashboard.
Anonymous(none)Public read-only endpoints only. Lowest rate limits.

Note: Clerk JWT is deprecated and no longer supported. Use Better Auth session tokens or API keys for all programmatic access. See docs/auth/README.md for full authentication documentation.

Rate Limits by Tier

TierLimitDescription
anonymous10 req/minPublic endpoints only
free60 req/minRegistered user
pro300 req/minPaid subscriber
adminUnlimitedAdministrator

REST API Endpoints

Base URL: https://bloqr-backend.jk-com.workers.dev/api
Local dev: http://localhost:8787/api

All endpoints return JSON. Streaming endpoints (/compile/stream) return text/event-stream.

Endpoint Summary

MethodPathAuth RequiredDescription
GET/apiNoAPI info — version, endpoints, usage examples
GET/api/versionNoCurrent deployment version
GET/api/schemasNoJSON Schemas for all public Zod types
GET/api/turnstile-configNoCloudflare Turnstile site key
GET/api/sentry-configNoSentry DSN for client-side error reporting
GET/api/openapi.jsonNoLive OpenAPI 3.0 specification
GET/api/deploymentsNoDeployment history
GET/api/deployments/statsNoDeployment statistics
GET/api/auth/providersNoActive authentication providers
POST/api/auth/sign-up/emailNoCreate account
POST/api/auth/sign-in/emailNoSign in (returns session token)
POST/api/auth/sign-outSessionSign out
GET/api/auth/get-sessionNoCurrent session info
Compilation
POST/api/compileFree+Synchronous JSON compilation
POST/api/compile/streamFree+SSE streaming compilation
POST/api/compile/batchFree+Synchronous batch compilation (max 10)
POST/api/compile/asyncPro+Async compilation (queue)
POST/api/compile/batch/asyncPro+Async batch compilation (queue)
POST/api/compile/containerFree+Container-based compilation
POST/api/ast/parseFree+Parse rules into AST
POST/api/validateFree+Validate filter list
POST/api/validate-ruleFree+Validate a single rule
GET/api/ws/compileFree+WebSocket real-time compilation
Queue
GET/api/queue/statsFree+Queue health metrics
GET/api/queue/historyFree+Job history
GET/api/queue/results/:idFree+Async job results
DELETE/api/queue/cancel/:idFree+Cancel pending job
Configuration
GET/api/configuration/defaultsNoSystem compilation defaults
POST/api/configuration/validateFree+Validate a configuration object
POST/api/configuration/resolveFree+Merge and resolve configuration layers
Rules
GET/api/rulesFree+List cached rule sets
GET/api/rules/:idFree+Get a specific rule set
Monitoring
GET/api/healthNoHealth check (cached 30s)
GET/api/health/latestNoLatest health snapshot
GET/api/health/db-smokeNoDatabase smoke test
GET/api/metricsNoAggregated performance metrics
GET/api/metrics/prometheusAdminPrometheus-format metrics
GET/api/container/statusNoContainer (DO) status
API Keys
GET/api/keysFree+List API keys
POST/api/keysFree+Create API key
DELETE/api/keys/:idFree+Revoke API key
Workflows
POST/api/workflow/compilePro+Start compilation workflow
GET/api/workflow/:idPro+Get workflow status
Admin
GET/api/admin/usersAdminList all users
GET/api/admin/users/:idAdminGet user by ID
PATCH/api/admin/users/:idAdminUpdate user
DELETE/api/admin/users/:idAdminDelete user
POST/api/admin/users/:id/banAdminBan user
POST/api/admin/users/:id/unbanAdminUnban user
GET/api/admin/auth/configAdminAuth configuration
GET/api/admin/usage/:userIdAdminUser API usage
ALL/api/admin/storage/*AdminStorage management
GET/api/admin/neon/projectAdminNeon project info
GET/api/admin/neon/branchesAdminNeon branches
POST/api/admin/neon/queryAdminRun Neon query
GET/api/admin/agents/sessionsAdminAgent sessions
tRPC
ALL/api/trpc/*VariestRPC v11 endpoint (see docs/architecture/trpc.md)

Usage Examples

Compile a Filter List (Sync)

Terminal window
curl -X POST https://bloqr-backend.jk-com.workers.dev/api/compile \
-H "Authorization: Bearer <session-token-or-api-key>" \
-H "Content-Type: application/json" \
-d '{
"configuration": {
"name": "My List",
"sources": [
{
"url": "https://raw.githubusercontent.com/easylist/easylist/master/easylist.txt",
"title": "EasyList"
}
],
"transformations": ["deduplicate", "validate"]
}
}'

Sign In and Get Session Token

Terminal window
curl -X POST https://bloqr-backend.jk-com.workers.dev/api/auth/sign-in/email \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "yourpassword"}'
# Response: { "token": "...", "user": { ... } }

Check API Health

Terminal window
curl https://bloqr-backend.jk-com.workers.dev/api/health
# Response: { "status": "healthy", "version": "<current-version>", "timestamp": "..." }

Queue an Async Compilation

Requires Pro tier. Anonymous and Free-tier callers receive a 403 Forbidden response.

Terminal window
# 1. Submit job
curl -X POST https://bloqr-backend.jk-com.workers.dev/api/compile/async \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{ "configuration": { "sources": [{ "url": "https://..." }] } }'
# Response: { "requestId": "req_abc123", "status": "queued" }
# 2. Poll for results
curl https://bloqr-backend.jk-com.workers.dev/api/queue/results/req_abc123 \
-H "Authorization: Bearer <token>"

TypeScript Library API

Tip: The TypeScript API reference is a separate static site generated from JSDoc annotations.

What is documented

Every symbol exported from the library’s main entry point (src/index.ts):

CategoryKey exports
CompilerFilterCompiler, SourceCompiler, IncrementalCompiler, compile()
TransformationsRemoveCommentsTransformation, DeduplicateTransformation, CompressTransformation, ValidateTransformation, …
PlatformWorkerCompiler, HttpFetcher, CompositeFetcher, PlatformDownloader
FormattersAdblockFormatter, HostsFormatter, DnsmasqFormatter, JsonFormatter, …
ServicesFilterService, ASTViewerService, AnalyticsService
DiagnosticsDiagnosticsCollector, createTracingContext, traceAsync, traceSync
UtilsRuleUtils, Logger, CircuitBreaker, CompilerEventEmitter, …
ConfigurationConfigurationSchema, ConfigurationValidator, all Zod schemas
TypesAll public interfaces (IConfiguration, ILogger, ICompilerEvents, …)
DiffDiffGenerator, generateDiff
PluginsPluginRegistry, PluginTransformationWrapper

Generating locally

Terminal window
# Generate the HTML API reference into docs/api-reference-site/
deno task docs:api
# Build the full Astro Starlight site + API reference in one step
deno task docs:build
# Live-preview the Astro Starlight site
deno task docs:serve

JSDoc conventions

/**
* Brief one-line description.
*
* @param inputRules - The raw rule strings to process.
* @returns The transformed rule strings.
* @example
* ```ts
* const result = new DeduplicateTransformation().executeSync(rules);
* ```
*/

See docs/development/CODE_REVIEW.md for the full documentation style guide.


Further Reading