Quick Start
Get started with the Fanbeam SDK in 5 minutes
Get started with the Fanbeam SDK in just a few minutes.
Step 1: Install the SDK
npm install fanbeamStep 2: Configure the Client
import { client } from 'fanbeam';
client.setConfig({
baseUrl: 'https://fanbeam.app/api',
headers: {
'X-API-Key': 'your-api-key-here'
}
});Step 3: Make Your First API Call
import { posts } from 'fanbeam';
// List posts
const response = await posts.list();
if (response.error) {
console.error('Error:', response.error);
} else {
console.log('Posts:', response.data);
}Complete Example
import { posts, media, channels, client } from 'fanbeam';
// Configure client
client.setConfig({
baseUrl: 'https://fanbeam.app/api',
headers: {
'X-API-Key': process.env.FANBEAM_API_KEY!
}
});
async function main() {
// List channels
const channelsResponse = await channels.list();
console.log('Channels:', channelsResponse.data);
// List posts
const postsResponse = await posts.list({
query: { page: 1, limit: 10 }
});
console.log('Posts:', postsResponse.data);
// Create a post
const createResponse = await posts.create({
body: {
title: 'My First Post',
body: 'Hello from the SDK!',
channelIds: ['channel-id-1']
}
});
console.log('Created post:', createResponse.data);
}
main().catch(console.error);