# SDKs

TypeScript, Python, C#, Java, PHP and Go clients generated from the contract, installed from the repository until they are published.

SDKs for six languages are generated from the same contract as this portal and versioned with it (the SDK version follows the contract version). They cover every operation an API key can call, customer level and operator level. **None is on a public registry yet**: install them from the repository (`platform/packages/sdk/<language>`).

| Language   | Package                               | What you get                                                                            |
| ---------- | ------------------------------------- | --------------------------------------------------------------------------------------- |
| TypeScript | `@wirebloom/sdk`                      | typed operations, auth, tenant, idempotency keys, pagination, retries, errors, webhooks |
| Python     | `wirebloom`                           | the same on httpx (sync and async) with pydantic models                                 |
| C#         | `WireBloom.Sdk`, `WireBloom.Webhooks` | generated client; webhook verifier                                                      |
| Java       | `com.wirebloom:wirebloom-sdk`         | generated client; webhook verifier                                                      |
| PHP        | `wirebloom/sdk`, `wirebloom/webhooks` | generated client; webhook verifier                                                      |
| Go         | `github.com/wirebloom/wirebloom-go`   | generated client; `webhooks` package                                                    |

The C#, Java, PHP and Go clients are generated with openapi-generator and are not committed: run `pnpm sdk:generate` (Docker or `openapi-generator-cli`) to write them into `generated/`. In every language the tenant is the customer id for customer-level keys and the operator id for operator-level keys, and the key is read from the environment, never written in code.

## TypeScript

Node.js 18+, Deno, Bun and edge runtimes; server-side only. `wb_live_` keys default to production and `wb_test_` keys to staging.

```ts
import { WireBloomClient } from '@wirebloom/sdk';

const wb = new WireBloomClient({
  apiKey: process.env.WIREBLOOM_API_KEY!,
  tenantId: process.env.WIREBLOOM_CUSTOMER_ID!,
});
const balances = await wb.call('listBalances');
for await (const tx of wb.paginate('listTransactions', { query: { limit: 100 } })) {
  console.log(tx.id, tx.amount);
}
```

Operations are called by `operationId`. Operations that take `Idempotency-Key` get a UUID v4 unless you pass `idempotencyKey`; retries reuse it.

## Python

Python 3.9+. Install from the repository: `pip install ./platform/packages/sdk/python`.

```python
import os
from wirebloom import WireBloom

with WireBloom(os.environ["WIREBLOOM_API_KEY"], tenant_id=os.environ["WIREBLOOM_CUSTOMER_ID"]) as wb:
    balances = wb.call("listBalances")
    for tx in wb.paginate("listTransactions", query={"limit": 100}):
        print(tx.id, tx.amount.amount_minor)
```

`AsyncWireBloom` is the async twin. Errors are typed: `AuthenticationError` (401), `PermissionDeniedError` (403), `NotFoundError`, `ConflictError`, `PreconditionError`, `ValidationError` (422), `RateLimitError`, `ServerError`, each with `.code` and `.request_id`.

## C#

.NET 8, from `platform/packages/sdk/csharp/generated` after `pnpm sdk:generate`.

```csharp
using WireBloom.Sdk.Api;
using WireBloom.Sdk.Client;

var config = new Configuration
{
    BasePath = "https://api.staging.banking.wirebloom.com/v1",
    AccessToken = Environment.GetEnvironmentVariable("WIREBLOOM_API_KEY"),
};
var balances = new AccountsApi(config)
    .ListBalances(Guid.Parse(Environment.GetEnvironmentVariable("WIREBLOOM_CUSTOMER_ID")!));
```

## Java

Java 11+, from `platform/packages/sdk/java/generated` (`mvn package`).

```java
import com.wirebloom.sdk.ApiClient;
import com.wirebloom.sdk.api.AccountsApi;
import java.util.UUID;

ApiClient client = new ApiClient();
client.updateBaseUri("https://api.staging.banking.wirebloom.com/v1");
client.setRequestInterceptor(request ->
    request.header("Authorization", "Bearer " + System.getenv("WIREBLOOM_API_KEY")));
var balances = new AccountsApi(client).listBalances(
    UUID.fromString(System.getenv("WIREBLOOM_CUSTOMER_ID")),
    null, null, null, null, null, null, null, null, null, null, null);
```

## PHP

PHP 8.1+, from `platform/packages/sdk/php/generated` (Composer, Guzzle).

```php
<?php
require_once __DIR__ . '/vendor/autoload.php';

$config = WireBloom\Sdk\Configuration::getDefaultConfiguration()
    ->setHost('https://api.staging.banking.wirebloom.com/v1')
    ->setAccessToken(getenv('WIREBLOOM_API_KEY'));
$api = new WireBloom\Sdk\Api\AccountsApi(new GuzzleHttp\Client(), $config);
$balances = $api->listBalances(getenv('WIREBLOOM_CUSTOMER_ID'));
```

## Go

From `platform/packages/sdk/go/generated` (module path `github.com/wirebloom/wirebloom-go`, a placeholder until it is published).

```go
cfg := wirebloom.NewConfiguration()
cfg.Servers = wirebloom.ServerConfigurations{{URL: "https://api.staging.banking.wirebloom.com/v1"}}
client := wirebloom.NewAPIClient(cfg)
ctx := context.WithValue(context.Background(), wirebloom.ContextAccessToken, os.Getenv("WIREBLOOM_API_KEY"))
balances, _, err := client.AccountsAPI.ListBalances(ctx).XTenantId(os.Getenv("WIREBLOOM_CUSTOMER_ID")).Execute()
```

## Webhook verifiers

Every language verifies `WireBloom-Signature` without extra dependencies:

| Language   | Verifier                                                                      |
| ---------- | ----------------------------------------------------------------------------- |
| TypeScript | `constructWebhookEvent`, `verifyWebhookSignature` (`@wirebloom/sdk/webhooks`) |
| Python     | `wirebloom.webhooks.construct_event`, `verify_signature`                      |
| C#         | `WireBloom.Webhooks.WebhookVerifier`                                          |
| Java       | `com.wirebloom.webhooks.WebhookVerifier`                                      |
| PHP        | `WireBloom\Webhooks\WebhookVerifier`                                          |
| Go         | `webhooks.Verify`                                                             |

All six pass the shared test vectors in `platform/packages/sdk/spec/webhook-test-vectors.json` (rotation, tampered body, stale timestamps and more); use them to test your own receiver. See [Webhooks](/docs/webhooks).

## Samples

`platform/examples/sdk-typescript` runs a complete flow on the TypeScript SDK against the sandbox: balances, a recipient, a payment sent twice with one `Idempotency-Key` (the second answer is the replay), a webhook endpoint whose test event is verified, then clean-up. Postman users start from the [Postman collection](/docs/postman).
