Authentication

In this section, you will find comprehensive information about the authentication process for the FinFeedAPI Prediction Markets. It covers the fundamental aspects and procedures involved in obtaining authentication for accessing prediction market functionality.

Authentication

In this section, you will find comprehensive information about the authentication process for the FinFeedAPI Prediction Markets. It covers the fundamental aspects and procedures involved in obtaining authentication for accessing prediction market functionality. Whether you are new to FinFeedAPI or seeking to enhance your understanding of the authentication process, this section will provide you with a valuable overview of the topic.

For prediction markets, we provide enhanced authentication methods to ensure secure access to trading functionality:

  • JWT token - Our primary authentication method. You sign short-lived JWT tokens with your own key, and each token names your JWT API key with its key ID in the kid header. This is mandatory for all prediction market operations to ensure secure trading and market creation.

  • OAuth access token - optional: sign in with your APIBricks account as an alternative to copying an API key. API keys keep working. An application that supports OAuth, for example an MCP client, opens the APIBricks sign-in page and sends the access token it receives in the Authorization: Bearer ACCESS_TOKEN header.

Authentication methods supported by the API

Here's an overview of the authentication methods supported by the Prediction Markets API. To access any prediction market resources, you must use JWT token authentication. The token is sent alone in the Authorization: Bearer JWT_TOKEN header and needs no API key next to it.

API ProductQuery paramURL pathAuthorization headerBasic authJWTOAuth access token
REST✅✅✅✅✅ (Required)✅
MCP✅✅✅✅✅✅

Integrations that send the API key in a custom header, the query string or the URL together with the token keep working. The API key cannot be sent in the Authorization header together with a token.

Query string parameter (apikey)

You can provide your API key by adding an apikey parameter to your HTTP request's query string.

Example: To create a new prediction market with API key abk_3f25....: POST /v1/markets/create?apikey=abk_3f25....

While the Query string method may be convenient for development, we recommend using more secure methods in production.

URL path

When passing the API key in the URL, format it with the APIKEY- prefix: If your API key is abk_3f25...., structure the URL as /APIKEY-abk_3f25.....

The API key can be placed at the end of the URL path. Examples:

  • /v1/markets/APIKEY-abk_3f25....
  • /APIKEY-abk_3f25....

Remember to include the APIKEY- prefix before your actual API key.

Authorization header

Include your API key directly in the Authorization header:

Authorization: abk_3f25....

Basic auth

Use Basic Authentication with a base64 encoded string combining your API key with the username "finfeedapi":

Authorization: Basic ZmluZmVlZGFwaTphYmtfM2YyNS4uLi4=

This example uses base64 encoding of "finfeedapi:abk_3f25....".

JWT token (Required)

JWT authentication is mandatory for all prediction market operations. This ensures secure access to trading functionality and market creation. JWTs must be passed via the Authorization header in the Bearer JWT_TOKEN format. The token is the only credential the request needs: its kid header holds the key ID of your JWT API key.

Supported JWT Algorithms

We support the following algorithms for JWT token verification:

  • RSASSA-PSS (e.g. PS256)
  • RSASSA-PKCS1-v1_5 (e.g. RS256)
  • ECDSA (e.g. ES256)
  • HMAC (e.g. HS256)

Setting Up JWT Authentication

To set up JWT authentication:

  1. In the customer portal, create a JWT key and import your public key (RSA or ECDSA), or the shared secret for HMAC
  2. Copy the key's Key ID from the API keys page of the customer portal
  3. Generate a JWT token with the Key ID in its kid header, signed with your private key or secret
  4. Send the token in the Authorization header using Bearer JWT_TOKEN format, without the API key
  5. Our server finds your key by the kid header and verifies the token with the key you imported

Example JWT Request

Add your JWT token to the Authorization header:

Authorization: Bearer JWT_TOKEN

Example with RS256 algorithm:

Authorization: Bearer eyJraWQiOiI5ODViMmQ0ZC1kMjE1LTQwN2MtODcxNi01NTIzNjA0YmM0ZTIiLCJhbGciOiJSUzI1NiJ9.ew0KICAic3ViIjogIjEyMzQ1Njc4OTAiLA0KICAibmFtZSI6ICJFWEFNUExFIFRPS0VOIiwNCiAgImlhdCI6IDE1MTYyMzkwMjIsDQogICJuYmYiOiAxNjg2MTM3MDI0LA0KICAiZXhwIjogMTcxNzY3MzAyNA0KfQ.CX6MWRSXQPKuQ_jrFCME91IwZhK8lq_2XrbDOyZ4-tPo0Ro52HA289sIfLo2LNafWQlq2lClfCN55TxyfC8n0xiifUwdec7g3kcGjCri6vTxaa8p6S3Fyyt2DxXccpi3Se4d_3mEQBZwMchKbQsw-W7Wj7njUk31ycgPQovvF4WrTuEYmhYw1sO9jCTORHmsSO7Shml7kv7AxlIUmzB2oq2KSmBhJV38Nz9oYj3KlPoMjgaIl4xYldNqnGyshh6fQyUQ1gQMQV6e4M5ro8YthjPOCvAT8yk77dTyOoE6Im58cAp6KtM-Gko-tWppUQTu-0M82LOvD_duP77n-hcoTw

Decoded JWT header:

{ "kid": "985b2d4d-d215-407c-8716-5523604bc4e2", "alg": "RS256" }

kid is the Key ID of your JWT API key. A request that sends only the token is rejected when kid is missing or names a different key.

Decoded JWT payload:

{
  "sub": "1234567890",
  "name": "EXAMPLE TOKEN",
  "iat": 1516239022,
  "nbf": 1686137024,
  "exp": 1717673024
}

JWT Token Requirements

All JWT tokens must include:

  • NBF (Not Before)

    • Specifies the earliest valid time for the token
    • Tokens with future "nbf" claims are rejected
  • EXP (Expiration Time)

    • Defines when the token expires
    • Expired tokens are rejected

Authentication Process

Our authentication process follows these steps:

  1. Extract the JWT from the Authorization header and find your API key by the Key ID in its kid header
  2. Verify the JWT signature and check NBF/EXP claims
  3. If valid, authorize the request and process it
  4. If invalid, return an error response

For prediction market operations, we also verify trading permissions and account status before processing requests.

OAuth access token

An application can get an access token by signing you in with your APIBricks account (OAuth 2.1, authorization code with PKCE) as an alternative to an API key. API keys keep working on every API; OAuth is optional. The authorization server is https://signin.apibricks.io, with its metadata at https://signin.apibricks.io/.well-known/oauth-authorization-server. Applications register themselves with dynamic client registration.

When you approve an application, you choose the organization, the product (or all products), a name for the key and when it expires. Approving creates a JWT API key in that organization. It is listed on the API keys page of the customer portal like any other JWT key, and deleting it disconnects the application immediately.

The application sends the access token alone in the Authorization header:

Authorization: Bearer ACCESS_TOKEN

Access tokens are valid for 1 hour. The application gets new ones with its refresh token, without asking you to sign in again.

A request without credentials is answered with 401 and a WWW-Authenticate: Bearer resource_metadata="..." header that points to the API's protected resource metadata (/.well-known/oauth-protected-resource, RFC 9728). The metadata names the authorization server, so MCP clients start the sign-in on their own.