Authentication

In this section, you will find comprehensive information about the process of FinFeedAPI authentication. It covers the fundamental aspects and procedures involved in obtaining authentication for FinFeedAPI usage. 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.

Authentication

In this section, you will find comprehensive information about the process of FinFeedAPI authentication. It covers the fundamental aspects and procedures involved in obtaining authentication for FinFeedAPI usage. 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.

There are different types of authentication methods available to secure and control access to its services.

  • API Key - fundamental method of authentication that involves the usage of an API key for authentication and access control.

The console shows a key as abk_, 32 hex characters and an 8 hex character checksum, for example abk_3f25..... Letter case does not matter. Send the value from the console. Keys that were already in use also still authenticate when sent as a GUID. A value that starts with abk_ but has a wrong checksum is rejected.

  • JWT token - extended authentication method for a JWT API key. You sign short-lived JWT tokens with your own private key or secret, and each token names its API key with the key ID in its kid header. A request then carries only the Authorization: Bearer JWT_TOKEN header, so the API key itself never has to leave your servers. Useful when you need to hand credentials to clients you do not control, for example when accessing the FinFeedAPI endpoints from the frontend JavaScript code exposed to the end-users.

  • 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 various products offered by FinFeedAPI and the supported authentication methods for each product. To use resources that require authorized access, you will need to use one of the many authentication methods described below.

API ProductQuery paramURL pathAuthorization headerBasic authJWTOAuth access token
REST✅✅✅✅✅✅
MCP✅✅✅✅✅✅

A JWT token is sent alone, in the Authorization: Bearer JWT_TOKEN header. Its kid header names your API key, so the request does not need the API key. 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 authorize by providing an additional parameter named apikey with a value equal to your API key in the query string of your HTTP request.

Assuming that your API key is abk_3f25.... and that you want to request all exchange rates from AAPL asset, then your query string should look like this: GET /v1/price/AAPL?apikey=abk_3f25....

The Query string method may be more practical for development activities.

:::

URL path

To ensure proper authentication when passing the API key in the URL, it is important to format it correctly. The real API key should always be preceded by the APIKEY- prefix, followed by the actual API key. For example, if your API key is abk_3f25...., the URL should be structured as /APIKEY-abk_3f25.....

The API key can be placed end of the URL path. Note that the key is completely ignored when determining the path of the requested resource. Here are examples of the different placements:

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

Please make sure to replace abk_3f25.... with your actual API key for authentication and access to the requested resources and remember to include the APIKEY- prefix before your real API key.

Authorization header

This method involves including the API key directly in the Authorization header of the API request.

Authorization: abk_3f25....

Basic auth

Use Basic Authentication by setting the Authorization header with a base64 encoded string that combines your API key with a username (finfeedapi):

Authorization: Basic ZmluZmVlZGFwaTphYmtfM2YyNS4uLi4=

In this example, ZmluZmVlZGFwaTphYmtfM2YyNS4uLi4= is a base64 encoded string of the username and API key (finfeedapi:abk_3f25....).

JWT token

The JWT authentication method provides a secure and efficient way to authorize requests using JSON Web Tokens (JWT). With this method, JWTs can 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

The JWT authentication method supports the following algorithms for JWT token verification with various key sizes:

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

Enabling JWT authentication

To enable JWT authentication for your API key:

  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 (it ensures the authenticity and integrity of the token).
  4. Send the token in the Authorization header of your API requests using the Bearer JWT_TOKEN format. Do not send the API key with it.
  5. Let the FinFeedAPI server find your key by the kid header and verify the token's signature with the key you imported in Step 1.

Example request with JWT authentication

To include a JWT in an API request, add the token to the Authorization header using the Bearer scheme. The format of the header is as follows:

Authorization: Bearer JWT_TOKEN

Example request header with JWT token generated using RS256 algorithm:

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

Decoded JWT token 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 token payload:

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

Generating a token

The example below signs a token that is valid for 5 minutes with Python and PyJWT (pip install "pyjwt[crypto]"). Any JWT library works the same way: set kid in the token header, nbf and exp in the payload, and sign with your private key.

import time
import jwt

KEY_ID = "985b2d4d-d215-407c-8716-5523604bc4e2"  # Key ID from the API keys page

with open("private_key.pem") as f:
    private_key = f.read()

now = int(time.time())
token = jwt.encode(
    {"nbf": now, "exp": now + 300},
    private_key,
    algorithm="RS256",
    headers={"kid": KEY_ID},
)

headers = {"Authorization": f"Bearer {token}"}

JWT Token expiration

To ensure the validity of JWT tokens and prevent the use of expired tokens, the inclusion of the following claims is required:

  • NBF (Not Before)

    • The "nbf" claim specifies the earliest time at which the token can be considered valid. Tokens with a "nbf" claim set in the future should not be accepted.
  • EXP (Expiration Time)

    • The "exp" claim defines the expiration time of the token. Tokens with an "exp" claim set in the past should not be accepted.

Request authentication

During the process of request authentication, the FinFeedAPI server follows a series of steps to ensure secure access to its resources. Here's an overview of the authentication process:

  1. Upon receiving the request, the FinFeedAPI server extracts the JWT from the Authorization header and finds your API key by the Key ID in the token's kid header.
  2. Then, it verifies the JWT signature and checks the "NBF" and "EXP" claims to ensure token validity and expiration.
  3. If the JWT is valid and not expired, the server authorizes the request and proceeds with the necessary processing to access FinFeedAPI resources.
  4. If the JWT is invalid or expired, the server returns an appropriate error response.

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.