Fanbeam
Fanbeam
Documentation
API Reference
Getting Started
User Guides
TypeScript SDK
AuthenticationError HandlingInstallationQuick StartTypeScript Types
TypeScript SDK

TypeScript Types

Understanding TypeScript types in the SDK

The Fanbeam SDK provides full TypeScript type safety. All types are automatically generated from the OpenAPI specification.

Response Types

All SDK methods return a response object with this structure:

type Response<T> = {
  data?: T;
  error?: {
    status: number;
    body: unknown;
  };
};

Example Types

Posts

// List posts response
type PostsListResponse = {
  posts: Post[];
  pagination: {
    page: number;
    limit: number;
    total: number;
  };
};

// Post type
type Post = {
  id: string;
  title: string;
  body: string;
  status: 'draft' | 'scheduled' | 'published' | 'archived';
  scheduledAt?: string;
  channelIds: string[];
  createdAt: string;
  updatedAt: string;
};

Media

// Media type
type Media = {
  id: string;
  filename: string;
  contentType: string;
  size: number;
  url: string;
  createdAt: string;
};

Channels

// Channel type
type Channel = {
  id: string;
  platform: 'instagram' | 'facebook' | 'linkedin' | 'twitter' | 'tiktok' | 'youtube' | 'pinterest' | 'bluesky' | 'threads';
  name: string;
  connectedAt: string;
};

Type Inference

TypeScript automatically infers types from method calls:

import { posts } from 'fanbeam';

// TypeScript knows the response type
const response = await posts.list();
// response.data is typed as PostsListResponse | undefined

if (response.data) {
  // TypeScript knows response.data is PostsListResponse here
  response.data.posts.forEach(post => {
    // post is typed as Post
    console.log(post.title);
  });
}

Custom Types

You can also import types directly:

import type { Post, Media, Channel } from 'fanbeam';

function processPost(post: Post) {
  // Type-safe post processing
}

Next Steps

  • Error Handling
  • Quick Start

Quick Start

Get started with the Fanbeam SDK in 5 minutes

Channels Examples

Examples for managing channels

On this page

Response TypesExample TypesPostsMediaChannelsType InferenceCustom TypesNext Steps