SDK Overview
The fnlb package is the self-hosted client. start() downloads the FNLB client, forks one process per shard, and logs those bots into Fortnite. Events, party meta, chat, and bot.runCommand talk to those processes over local IPC. fnlb.api is a separate HTTP client for the same account, including bots that are not running in this process. Install, tokens, shards, and shutdown stay on the Node.js SDK page. Every class and method is also in the SDK Reference. The machine-readable spec is /sdk.json. Generated Markdown for one symbol is under /sdk-reference, for example Party.
What you import
import FNLB, {
Events,
PartyPrivacy,
Playlist,
PresenceOnlineType,
ApiError,
SDK_BRIDGE_UNAVAILABLE
} from 'fnlb';| Export | Use it for |
|---|---|
FNLB | The client. start(), stop(), on, bots, api. Reference: FNLB. |
Events | Listener names. Reference: Events. |
PartyPrivacy | party.setPrivacy. Reference: PartyPrivacy. |
Playlist | Built-in playlist link ids for party.setPlaylist. Reference: Playlist. |
PresenceOnlineType | bot.setStatus. Reference: PresenceOnlineType. |
ApiError | Non-2xx responses from fnlb.api. Reference: ApiError. |
SDK_BRIDGE_UNAVAILABLE | Thrown when a shard never opens the local bridge. |
Bot, Party, PartyMember, PartyMeta, Message, and Collection are also exported if you want the types. You normally receive them from fnlb.on and fnlb.bots.
Two ways to talk to a bot
| Local shard | HTTP API | |
|---|---|---|
| When | The bot is running in this process | Any bot on the account, online or not |
| Entry | fnlb.bots, bot.party, fnlb.on | fnlb.api after start() |
| Party meta | bot.party.meta and bot.party.me.meta | Not available. The API member route is a cosmetic snapshot. |
| Commands | bot.runCommand | fnlb.api.bots.commands.run |
| Chat | bot.send, bot.whisper, message.reply | fnlb.api.bots.chat.send |
| Friends | bot.friends(), addFriend, block | api.bots.friends.list reads a connected bot. It does not add or block. |
| Cosmetics | party.setOutfit and the other member methods | A command through commands.run, or a category config outfit list |
Guides
- Events
Ready, chat, friends, invites, joins, and cosmetic changes.
- Bots and parties
Members, meta, privacy, playlists, and cosmetics.
- Chat and commands
Party chat, whispers, friend requests, and local commands.
- HTTP client
List bots, categories, presets, and run cloud commands.
- Category config
Keys for
overrideCategoryConfigand selection overrides. - Node.js SDK
Install, authenticate, shard, and stop the process.
- SDK Reference
Generated classes, methods, and types.
A complete loop
import FNLB, { Events, PartyPrivacy, Playlist } from 'fnlb';
const fnlb = new FNLB({ clusterName: 'dev' });
fnlb.on(Events.Ready, (bot) => {
console.log(bot.displayName, 'is ready');
});
fnlb.on(Events.PartyMemberMessage, async (message) => {
if (message.content === '!ping') await message.reply('pong');
});
await fnlb.start({
token: 'FNLB_...',
categories: ['your-category-id']
});
const bot = await fnlb.bots.fetch('bot-id');
await bot.party.setPrivacy(PartyPrivacy.PRIVATE);
await bot.party.setPlaylist(Playlist.SQUAD);
await bot.party.setOutfit('CID_028_Athena_Commando_F');
await bot.party.meta.set('Default:CustomMatchKey_s', 'my-key');
const accountBots = await fnlb.api.bots.list();fnlb.bots.cache only contains bots this process has started. fnlb.api.bots.list() is every bot on the token.
Shards
Each shard is a child process. fnlb.shards holds them after start(). fnlb.fetchShardInfo() returns version, protocol, gateway connection, and bot count for each one. fnlb.broadcast(method, params) sends one bridge call to every shard and returns a result per shard. A failed shard is ok: false and does not reject the whole call. Prefer fnlb.bots for party, chat, and commands. Use the shard when you want Shard.fetchInfo.
When a call throws
| Error | Cause |
|---|---|
SDK_BRIDGE_UNAVAILABLE | The shard never announced the bridge. The downloaded FNLB client is too old, or it exited before hello. |
Bot <id> is not running on this client. | fetch was asked for a bot this process did not start. Use fnlb.api.bots.get for account bots. |
Only this bot can change its own member. | party.members.get(someoneElse).setOutfit (or any other self-only member method). |
| Party leader errors from Fortnite | setPrivacy, kick, setPlaylist, and the other leader calls when this bot is not the leader. |
ApiError | fnlb.api got a non-2xx response. status, path, and body are on the error. |
Local party calls need a current FNLB client. An older build rejects fortnite.action with an unknown-method error. fnlb.api still works on that build.
Where to go next
| You want to | Read |
|---|---|
| Hear ready, chat, invites, and cosmetic changes | Events |
| Change privacy, playlist, meta, or cosmetics | Bots and parties |
Chat, friends, and runCommand | Chat and commands |
| Create bots, categories, or run a cloud command | HTTP client |
| Override dashboard settings for this run | Category config |
| Install, tokens, and shard counts | Node.js SDK |