Catching up
An event can be missed: bot stopped, receiving endpoint unreachable past the retries. The service's API returns the current state, and its client lives in its own module, which loads neither node:http nor node:crypto.
import { createClient } from '@fca.gg/lfp-webhooks/client'
const api = createClient({
baseUrl: process.env.LFP_API_URL,
token: process.env.LFP_API_TOKEN,
})
const state = await api.match('2640560')
const live = await api.matches({ season: '2026', matchday: 3 })
const table = await api.standings('24', '2026')
const stats = await api.player('54321', { season: '2026' })
const lineup = await api.lineupImage('2640560', { side: 'home' })
Options
baseUrl: the root of the service's API;token: the API token; without it, requests go out with no authorization header;timeout: when to give up on a request, in milliseconds (10,000 by default).
Methods
| Method | Returns |
|---|---|
match(matchId) | the full state of a match: info, teams, lineup, goals, cards, substitutions; null if unknown |
matches({ competition, season, matchday }) | the matching matches |
standings(competitionId, season) | a competition's standings |
players({ search, team }) | the players found |
player(playerId, { season, competition }) | a player's aggregated stats and the detail of their matches; null if unknown |
lineupImage(matchId, { side, etag }) | the lineup image, as a transparent PNG: { image, etag } |
health() | the service's status |
side is home, away or both. Pass the etag of an image you already have: if it has not changed, the service answers 304 and the method returns null, without downloading the image again.
Errors
A 404 response becomes null. Any other error throws an ApiError carrying its status, which tells a service response apart from a network failure:
import { ApiError } from '@fca.gg/lfp-webhooks/client'
try {
await api.standings('24', '2026')
} catch (error) {
if (error instanceof ApiError && error.status === 401) console.error('Token rejected')
else throw error
}
Two tokens, two directions
| Channel | Direction | Token |
|---|---|---|
| Webhooks | service → bot | checked by createReceiver({ token }) |
| API | bot → service | presented by createClient({ token }) |
They are two separate secrets: the webhook one goes to the receiver with every delivery, the other opens the API for reading. Giving them the same value would turn a leak of one into a leak of the other.