A typescript client wrapper for the osirion public api
This package makes it easy to use our public api for fortnite match data.
We recommend checking out the generated docs for our package on tsdocs.dev at https://tsdocs.dev/docs/@osirion/api.
To use the api, you need to:
- Create an osirion account on our website
- Generate an api key under account settings
- Load up on some api credits under account settings
Once done, you can use the @osirion/api
library.
Each api call costs credits, and 1000 credits is about equal to €1.
- Uploading replays costs 20 credits (~€0.02).
- Ping costs 1 credit per request (0.001€).
- Every other request is charged based on a pay-as-you-go compute model. Credits are charged per second of compute used, with a 10-second minimum.
- Match events are charged the same way but scaled by the number of events being requested. With a maximum of 8 events being charged.
Note that this is subject to change as we develop the api further.
Install the @osirion/api
package with your preferred package manager.
pnpm
pnpm add @osirion/api
npm
npm i @osirion/api
yarn
yarn add @osirion/api
Then, initialize the client:
import { OsirionClient } from '@osirion/api';
const osirion = new OsirionClient('<OSIRION_API_KEY>');
Once initialized, you can make async calls to request fortnite match data or upload fortnite replays to-be-parsed.
You can upload a replay by its filepath or the file buffer.
import fsp from 'fs/promises';
const filepath = '/path/to/file.replay';
// buffer
const buffer = await fsp.readFile(filepath);
const trackingId = await osirion.uploadReplay(buffer);
// filepath
const trackingId = await osirion.uploadReplay(filepath);
This uploads all replays in your demos folder, remember that one replay costs 20 credits, so this will likely cost a lot of credits.
const demoDir = `${process.env.LOCALAPPDATA}/FortniteGame/Saved/Demos`;
const demoDirEntries = await fsp.readdir(demoDir);
const demos = demoDirEntries.filter((f) => f.endsWith('.replay'));
for (const demo of demos) {
const trackingId = await osirion.uploadReplay(`${demoDir}/${demo}`);
console.info(`Uploaded ${demo}: ${trackingId}`);
}
You can check the status of a uploaded replay with the returned track id.
const result = await osirion.getUploadStatus("<TrackingId>");
// pending
{
status: 'PENDING',
matchId: ''
}
// parsed
{
status: 'COMPLETE',
matchId: 'e55969a0a86d7b4e843e912f752c2a35'
}
This operation returns a sorted list of the matches for specified Epic IDs. Include options to select from specific time periods, seasons, or to limit the number of returned matches.
const matches = await osirion.getMatches(['<EpicAccountId1>', '<EpicAccountId2>']);
You can get basic info about a match using a match ID.
const match = await osirion.getMatchInfo('<MatchId>');
You can get specific events from a match.
// here we get all cosmetic and normal player events
const events = await osirion.getMatchEvents('<MatchId>', ['cosmeticsV2', 'players']);
You can get the available credits left on your osirion account.
const credits = await osirion.getCredits();
You can get player stats for tournaments with filters (stats from server replays).
// get player stats for that specific event window (tournament session)
const playerStats = await osirion.getTournamentPlayerStats({
eventWindowId: 'S34_PerformanceEvaluation_Event1Round1_EU',
});
The public api is in its early stages, and it may have periods of downtime. This client wrapper library may also have bugs and issues, and the docs may be outdated.
If you have questions or feedback, please contact the Osirion team on our discord server.