Skip to main content

Installation

Prerequisites

  • A Xenarch publisher account
  • A registered site with site token and site ID
  • Your access token secret (from site registration)

Pattern 1: Site-wide middleware

Gates all bot traffic across your application:

Parameters

Pattern 2: Per-route decorator

Gates individual routes:
The decorated function must accept a request: Request parameter.

How it works

  1. Checks User-Agent against known bot signatures
  2. If bot: checks Authorization: Bearer header for a valid access token
  3. Valid token: verifies HMAC signature, checks expiry, checks site_id — all local, no API call
  4. No token: calls POST /v1/gates to create a gate, returns HTTP 402

Testing

Full example

See the FastAPI publisher example for a complete working application.