TypeScript SDKExamples
Posts Examples
Examples for working with posts using the SDK
Complete examples for managing posts with the Fanbeam SDK.
List Posts
import { posts } from 'fanbeam';
// List all posts
const response = await posts.list();
// With pagination
const paginatedResponse = await posts.list({
query: {
page: 1,
limit: 20
}
});
// With filters
const filteredResponse = await posts.list({
query: {
status: 'scheduled',
channelId: 'channel-id-1'
}
});Get Post
import { posts } from 'fanbeam';
const response = await posts.get({
params: { id: 'post-id' }
});
if (response.data) {
console.log('Post:', response.data);
}Create Post
import { posts } from 'fanbeam';
const response = await posts.create({
body: {
title: 'My Post',
body: 'Post content with #hashtags and @mentions',
scheduledAt: new Date('2024-01-01T12:00:00Z'),
channelIds: ['channel-id-1', 'channel-id-2']
}
});Update Post
import { posts } from 'fanbeam';
const response = await posts.update({
params: { id: 'post-id' },
body: {
title: 'Updated Title',
body: 'Updated content'
}
});Delete Post
import { posts } from 'fanbeam';
const response = await posts.remove({
params: { id: 'post-id' }
});Schedule Post
import { posts } from 'fanbeam';
const response = await posts.schedule({
params: { id: 'post-id' },
body: {
scheduledAt: new Date('2024-01-01T12:00:00Z')
}
});Archive Post
import { posts } from 'fanbeam';
// Archive
await posts.archive({
params: { id: 'post-id' }
});
// Unarchive
await posts.unarchive({
params: { id: 'post-id' }
});Bulk Operations
import { posts } from 'fanbeam';
// Bulk delete
await posts.bulkDelete({
body: {
ids: ['post-id-1', 'post-id-2', 'post-id-3']
}
});
// Bulk archive
await posts.bulkArchive({
body: {
ids: ['post-id-1', 'post-id-2']
}
});