Authentication
You use one API key for REST and WebSocket. Webhooks work the other way around: finlight calls you and signs each request. This page shows how the key is sent on each channel.
Get your API key
Sign in to the finlight Dashboard and open the API Keys section. Create a key there. You can create more than one key, for example one per application, and delete a key you no longer need.
Your plan belongs to your account, not to a single key. Every key of your account shares the same credits and limits.
REST
Send the key in the X-API-KEY header with every request.
Request
curl -X POST 'https://api.finlight.me/v3/articles/search' \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: YOUR_API_KEY' \
-d '{"query":"ticker:NVDA","limit":5}'
A missing or wrong key gets a 401 with code UNAUTHORIZED. The body is the same for both cases:
401 Unauthorized
{
"type": "https://docs.finlight.me/errors/unauthorized",
"title": "Unauthorized",
"status": 401,
"detail": "Unauthorized",
"code": "UNAUTHORIZED",
"requestId": "req_f4673a11-cc66-4e06-8435-7e43d06ee038"
}
A valid key that is not allowed to use a feature gets a 403 with code FORBIDDEN, for example a company lookup on a plan without company data. See Unauthorized and Forbidden.
WebSocket
The WebSocket takes the key when you connect. You have two ways to send it:
- the
x-api-keyheader, written in lowercase, or - the
apiKeyquery parameter:wss://wss.finlight.me?apiKey=YOUR_API_KEY.
The header name is matched exactly. X-API-KEY or X-Api-Key is not found, and the connection is refused with 401. Some HTTP libraries change the case of header names on their own (Go's Header.Set is one). If yours does, set the header map directly or use the query parameter.
Browsers cannot set headers on a WebSocket, so a browser has to use ?apiKey=.
Connect
import WebSocket from 'ws'
const socket = new WebSocket('wss://wss.finlight.me', {
headers: { 'x-api-key': process.env.FINLIGHT_API_KEY! },
})
The official clients do this for you: client.stream(...) connects with your key and picks the right form. Without a key the connection is refused with 401 and the body {"error":"Missing API-KEY"}. Most WebSocket libraries only show you the status code. The full list of refusals is on Connect.
Webhooks
Webhooks do not use your API key. finlight sends a POST to your URL and signs the body with your webhook secret. Your server checks the signature in the X-Webhook-Signature header. See Signature verification.
You can also ask finlight to send a fixed value with each delivery, for example an X-Finlight-Key header or basic auth. You choose this when you set up the webhook.
You create and manage webhooks in the dashboard, signed in with your finlight account. API v3 has no API-key route to create or change webhooks. Only the Zapier and Make integrations create webhooks with your API key, and those are v2 webhooks. See Webhooks overview & setup.
Request ids
You can send an X-Request-Id header with any REST request. If the request fails, the error body repeats it as requestId. If you do not send one, the server makes one up in the form req_<uuid>.
curl -X POST 'https://api.finlight.me/v3/articles/search' \
-H 'Content-Type: application/json' \
-H 'X-Request-Id: test-123' \
-d '{"limit":1}'
401 Unauthorized
{
"type": "https://docs.finlight.me/errors/unauthorized",
"title": "Unauthorized",
"status": 401,
"detail": "Unauthorized",
"code": "UNAUTHORIZED",
"requestId": "test-123"
}
- The id only appears in error bodies. It is not sent back as a response header, and successful answers do not carry it.
- The official clients send their own
X-Request-Idwith each call and reuse it for retries. They put it on the error object asrequestId(request_idin Python). - When you contact support about a failed request, include the
requestId.
Keep your key secret
Treat your API key like a password. Anyone who has it can use your credits.
- Keep the key on your server. Read it from an environment variable or a secret store, not from source code.
- Do not put the key in a web page or a mobile app. A key in a browser is visible to every visitor. Only use
?apiKey=in a browser for short tests with a key you delete afterwards. - A URL with
?apiKey=can end up in logs and proxies. On a server, prefer thex-api-keyheader. - If a key leaks, delete it in the dashboard and create a new one.
- To change a key without downtime, create the new key first, switch your application to it, and only then delete the old key. Both keys work at the same time and share the same credits.