Prediction Router
API Reference

Logs & Analytics

Opt-in operation logging and history — a Pro plan feature

Operation logging is a Pro feature. When enabled, Prediction Router records a credential-free summary of each trading/account request — what you did and how it turned out — so you can query your history and build analytics. Nothing sensitive is ever stored: logs never contain credentials, only the shape of the request and its outcome.

Logging is opt-in per request and best-effort — a logging failure never affects the underlying operation.

All endpoints require Authorization: Bearer <key>.

Base URL: https://prediction-router-api.kalashshah47.workers.dev


Enabling logging on a request

Add the X-Enable-Log header to any trading or account request to record it:

X-Enable-Log: true

The response echoes what happened via the X-Log-Status header:

X-Log-StatusMeaning
recordedThe operation was logged (Pro plan)
skipped_plan_requiredYou asked to log but are on the free plan — the request still ran, nothing was logged

On the free plan the header is simply ignored (aside from the skipped_plan_required signal); upgrade to Pro to record and query history.

Example

curl -X POST "https://prediction-router-api.kalashshah47.workers.dev/v1/orders" \
  -H "Authorization: Bearer pr_..." \
  -H "X-Platform-Credential: $CRED" \
  -H "X-Enable-Log: true" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "kalshi",
    "marketId": "KXFED-0325",
    "outcomeId": "yes",
    "side": "buy",
    "amount": 25,
    "price": 0.28
  }'

GET /v1/plan

Return the caller's current plan. Use it to show the right upgrade state in your client.

Example

curl "https://prediction-router-api.kalashshah47.workers.dev/v1/plan" \
  -H "Authorization: Bearer pr_..."

Response

{ "plan": "free" }

plan is "free" or "pro".


GET /v1/logs

List your recorded operations, newest first. Pro only — returns 402 on the free plan.

Query parameters

ParameterTypeRequiredDescription
platformstringFilter to a single platform
operationstringFilter to one operation — e.g. place_order, get_orders, cancel_order, get_balance, get_positions, get_history
limitintegerMax results. Default 50, max 200
offsetintegerPagination offset. Default 0

Example

curl "https://prediction-router-api.kalashshah47.workers.dev/v1/logs?platform=kalshi&operation=place_order&limit=20" \
  -H "Authorization: Bearer pr_..."

Response

{
  "logs": [
    {
      "id": "log_abc123",
      "userId": "a1b2c3...",
      "platform": "kalshi",
      "operation": "place_order",
      "status": "success",
      "marketId": "KXFED-0325",
      "outcomeId": "yes",
      "side": "buy",
      "amount": 25,
      "price": 0.28,
      "orderId": "ord_abc123",
      "errorCode": null,
      "latencyMs": 412,
      "createdAt": "2026-06-19T10:00:00.000Z"
    }
  ]
}

Log record fields

FieldTypeDescription
idstringLog record ID
userIdstringYour user ID
platformstringPlatform the operation ran against
operationstringplace_order, get_orders, cancel_order, get_balance, get_positions, get_history
statusstringsuccess or error
marketIdstring | nullMarket ID, when applicable
outcomeIdstring | nullOutcome ID, when applicable
sidestring | nullbuy or sell, when applicable
amountnumber | nullOrder amount, when applicable
pricenumber | nullLimit price, when applicable
orderIdstring | nullResulting order ID on a successful order
errorCodestring | nullError code when status is error
latencyMsnumber | nullOperation latency in milliseconds
createdAtstringISO 8601 timestamp

No credential or account-acting data is ever included.

Errors

StatusCodeMeaning
400VALIDATION_ERRORInvalid query parameters
402PLAN_REQUIREDLogging & analytics is a Pro feature — upgrade to record and query history