Predict API (Beta)
  1. Guides
  • FAQs
  • Deployed Contracts
  • Guides
    • Understanding the Orderbook
    • [TS] How to authenticate your API requests
    • [PY] How to authenticate your API requests
    • How to create or cancel orders
  • WebSocket
    • General Information
    • Request Format
    • Response Format
    • Subscription Topics
    • Heartbeats
    • Client Example
  • Authorization
    • Get auth message
      GET
    • Get JWT with valid signature
      POST
  • Categories
    • Get categories
      GET
    • Get category by slug
      GET
    • Get all tags
      GET
  • Markets
    • Get markets
      GET
    • Get market by ID
      GET
    • Get market statistics
      GET
    • Get market last sale information
      GET
    • Get the orderbook for a market
      GET
    • Get market timeseries
      GET
    • Get latest market timeseries value
      GET
  • Orders
    • Get order by hash
      GET
    • Get orders
      GET
    • Get order match events
      GET
    • Remove orders from the orderbook
      POST
    • Create an order
      POST
  • Accounts
    • Get connected account
      GET
    • Get account activity
      GET
    • Set a referral
      POST
  • Positions
    • Get positions
      GET
    • Get positions by address
      GET
  • Search
    • Search categories and markets
      GET
  • OAuth
    • Finalize a OAuth connection
      POST
    • Get the orders for a OAuth connection
      POST
    • Create an order for a OAuth connection
      POST
    • Cancel the orders for a OAuth connection
      POST
    • Get the positions for a OAuth connection
      POST
  • Schemas
    • AccountData
    • AccountResponse
    • ActivityEvent
    • ActivityEventName
    • ActivityOrderData
    • ActivityResponse
    • AuthMessageData
    • AuthMessageResponse
    • AuthTokenData
    • AuthTokenResponse
    • CategoriesResponse
    • CategoryResponse
    • CategorySort
    • CategoryStatsData
    • CategoryStatsResponse
    • CategoryStatus
    • CategoryStatusFilter
    • ContractOrder
    • CreateOrderData
    • CreateOrderRequest
    • CreateOrderResponse
    • CreateOrderResponseData
    • CryptoUpDownVariantData
    • ErrorCode
    • ErrorResponse
    • Fee
    • FeeType
    • LastOrderSettled
    • LastSaleData
    • LastSaleResponse
    • Market
    • MarketResponse
    • MarketSort
    • MarketStatsData
    • MarketStatsResponse
    • MarketStatus
    • MarketStatusFilter
    • MarketTradingStatus
    • MarketVariant
    • MarketsResponse
    • MatchData
    • MatchesResponse
    • Metric
    • OAuthCancelOrdersData
    • OAuthCancelOrdersRequest
    • OAuthCancelOrdersResponse
    • OAuthCreateOrderData
    • OAuthCreateOrderRequest
    • OAuthCreateOrderResponse
    • OAuthFinalizeData
    • OAuthFinalizeRequest
    • OAuthFinalizeResponse
    • OAuthOrdersData
    • OAuthOrdersRequest
    • OAuthOrdersResponse
    • OAuthPositionsData
    • OAuthPositionsRequest
    • OAuthPositionsResponse
    • OrderData
    • OrderFillData
    • OrderResponse
    • OrderStatus
    • OrderStatusFilter
    • OrderStrategy
    • OrderbookData
    • OrderbookResponse
    • OrdersResponse
    • Outcome
    • OutcomeSide
    • OutcomeStatus
    • PointsInfo
    • PositionData
    • PositionSort
    • PositionsResponse
    • PostAuthRequest
    • PriceFeedProvider
    • QuoteType
    • ReferralInfo
    • ReferralStatus
    • RemoveOrdersData
    • RemoveOrdersRequest
    • RemoveOrdersResponse
    • ReservedBalancePolicy
    • Resolution
    • ResolutionProvider
    • SearchData
    • SearchResponse
    • SelfTradePreventionStrategy
    • SetReferralData
    • SetReferralRequest
    • SetReferralResponse
    • Tag
    • TagsResponse
    • TimeseriesData
    • TimeseriesLatestData
    • TimeseriesLatestResponse
    • TimeseriesPoint
    • TimeseriesResponse
    • TweetCountVariantData
    • VariantData
    • VariantData_CryptoUpDownVariantData
    • VariantData_TweetCountVariantData
  1. Guides

[TS] How to authenticate your API requests

Authentication with API Key and JWT Token#

To interact with Predict's API, you'll need two things:
1.
API Key: Required for all endpoints (only on Mainnet).
2.
JWT Token: Required for performing personal operations for a specific wallet (e.g., sending a new order or viewing active orders).
Sections:
Obtaining a JWT Token (for EOAs)
Obtaining a JWT Token (for Predict accounts)
Passing the API Key and JWT Token in the requests

Obtaining a JWT Token (for Predict accounts)#

An API key is required to obtain a JWT token. Follow these steps to generate a JWT token for your wallet:
1.
Retrieve the message to sign:
Send a GET request to /v1/auth/message to retrieve a message for signing.
2.
Sign the message with your wallet via our SDK:
You will need two wallets:
Your Predict account address (aka deposit address)
Your Privy Wallet private key (can be exported from the account's settings)
NOTE: It's reccomended to fund your Privy Wallet with BNB to be able to set approvals and cancel orders.
3.
Send the signature:
Send a POST request to /v1/auth with the following JSON structure:

Obtaining a JWT Token (for EOAs)#

An API key is required to obtain a JWT token. Follow these steps to generate a JWT token for your wallet:
1.
Retrieve the message to sign:
Send a GET request to /v1/auth/message to retrieve a message for signing.
2.
Sign the message with your wallet:
Use the wallet you want to authenticate with to sign the message retrieved in step 1.
3.
Send the signature:
Send a POST request to /v1/auth with the following JSON structure:

Passing the API Key and JWT Token in Requests#

To authenticate your requests, you need to include both the API key and the JWT token in the request headers. The API key and x-api-key header are not required on Testnet.
Request headers (as shown on the example above):
{
  "headers": {
    "x-api-key": "YOUR_API_KEY",
    "Authorization": "Bearer YOUR_JWT_TOKEN"
  }
}
Example usage:
Modified at 2025-12-17 15:19:32
Previous
Understanding the Orderbook
Next
[PY] How to authenticate your API requests
Built with