Client Setup & Configuration

Configure the Switchboard client library to begin communicating with your API server. Both C# and TypeScript clients require a target Base URL and a valid authentication Key.


C# (.NET) Client Setup

The .NET client is packaged under the Switchboard.Client namespace and supports both dependency injection (DI) and static factory initialization.

1. Register with Dependency Injection

In ASP.NET Core applications, background workers, or MAUI mobile apps, register the client using the service extension:

using Switchboard.Client.DependencyInjection;

// Registers IRequestAdapter and SwitchboardClient into the DI container
builder.Services.AddSwitchboardClient(
    baseUrl: "https://switchboard.dnpcloud.com",
    apiKey: "your-api-key"
);

You can then inject SwitchboardClient directly into your services:

public class PhotoProcessor(SwitchboardClient client)
{
    // Use the injected client here
}

2. Static Factory Setup

For console utilities, unit tests, or scripts that do not run inside a host container, instantiate the client using the factory:

using Switchboard.Client;

var client = SwitchboardClientFactory.Create(
    baseUrl: "https://switchboard.dnpcloud.com", 
    apiKey: "your-api-key"
);

TypeScript (Node.js & Web) Client Setup

The TypeScript client requires a fetch-compatible runtime environment (natively supported in Node.js 18+ and all modern browsers).

Static Factory Setup

Instantiate the client directly using the SwitchboardClientFactory:

import { SwitchboardClientFactory } from '@switchboard/client';

const client = SwitchboardClientFactory.create(
  'https://switchboard.dnpcloud.com',
  'your-api-key'
);
Note

Since the TypeScript client uses standard modern ECMAScript modules, make sure your project is configured with "type": "module" in package.json or supports ESM module resolution.