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

Authentication

Authenticate SDK requests with API keys

The Fanbeam SDK uses API keys for authentication. Configure your API key when setting up the client.

Setting Your API Key

Global Configuration

import { client } from 'fanbeam';

client.setConfig({
  baseUrl: 'https://fanbeam.app/api',
  headers: {
    'X-API-Key': 'your-api-key-here'
  }
});

Environment Variables

import { client } from 'fanbeam';

client.setConfig({
  baseUrl: 'https://fanbeam.app/api',
  headers: {
    'X-API-Key': process.env.FANBEAM_API_KEY!
  }
});

Per-Request Configuration

You can also pass a custom client instance to individual requests:

import { posts, createClient } from 'fanbeam';

const customClient = createClient({
  baseUrl: 'https://fanbeam.app/api',
  headers: {
    'X-API-Key': 'different-api-key'
  }
});

const response = await posts.list({
  client: customClient
});

Getting Your API Key

  1. Log in to your Fanbeam account
  2. Navigate to Settings → API Keys
  3. Click Create API Key
  4. Copy the API key (it's only shown once)

Security Best Practices

  • Never commit API keys - Use environment variables
  • Rotate regularly - Generate new keys periodically
  • Use separate keys - Different keys for dev/staging/prod
  • Revoke unused keys - Delete keys that are no longer needed

Next Steps

  • Quick Start
  • Error Handling

TypeScript SDK

Type-safe SDK for the Fanbeam API

Error Handling

Handle errors in the SDK

On this page

Setting Your API KeyGlobal ConfigurationEnvironment VariablesPer-Request ConfigurationGetting Your API KeySecurity Best PracticesNext Steps