# SDKs

Official clients are generated from the [OpenAPI specification](https://sigwise.ai/docs/guide/openapi.md),
so every endpoint and schema in the [API reference](https://sigwise.ai/docs/reference.md) is available,
typed, in each language.

| Language | Package | Requires |
|----------|---------|----------|
| Node.js / TypeScript | `@sigwise/node` | Node 18+, no dependencies |
| Python | `sigwise-sdk` | Python 3.8+, no dependencies |
| Go | `github.com/thesigwise/sigwise-go` | Go 1.21+, standard library only |
| PHP | `sigwise/sdk` | PHP 8.1+ with `ext-curl` |
| Ruby | `sigwise` | Ruby 2.7+, no dependencies |

## Install

Node.js:

```bash
npm install @sigwise/node
```

Python:

```bash
pip install "git+https://github.com/thesigwise/sigwise-python"
```

Go:

```bash
go get github.com/thesigwise/sigwise-go
```

PHP:

```bash
composer config repositories.sigwise vcs https://github.com/thesigwise/sigwise-php
composer require sigwise/sdk:dev-main
```

Ruby:

```ruby
# In your Gemfile, then run: bundle install
gem "sigwise", git: "https://github.com/thesigwise/sigwise-ruby", branch: "main"
```

The Node.js SDK is on [npm](https://www.npmjs.com/package/@sigwise/node) and the
Go module installs from its repository. The Python, PHP and Ruby SDKs install
straight from their GitHub repositories
([Python](https://github.com/thesigwise/sigwise-python),
[PHP](https://github.com/thesigwise/sigwise-php),
[Ruby](https://github.com/thesigwise/sigwise-ruby)) until they are published
to PyPI, Packagist and RubyGems.

## What every SDK does

- **Signs every request** with your key's secret: a fresh 60-second HS256
  token bound to the request's method and path. The secret is never sent.
- **Reads your credentials from the environment:** `SIGWISE_API_KEY` and
  `SIGWISE_SECRET`. It talks to the production API; optionally, set
  `SIGWISE_BASE_URL` to point it at another deployment.
- **Retries safely:** idempotent requests (`GET`, `PUT`, `DELETE`) are retried
  after network errors, `429` and `5xx`, with exponential backoff; `POST`
  requests never are.
- **Raises typed errors** with the HTTP status, the error `code` and message.
- **Verifies webhooks:** a helper checks `X-Webhook-Signature` and the
  timestamp and parses the payload.

## Same API, idiomatic in each language

Resources and methods follow the API: `objects.get`, `events.ingest`,
`signals.upsert`, `webhooks.create` and so on.

Node.js:

```ts
import { SigWise } from "@sigwise/node";

const sigwise = new SigWise({ apiKey: "your_key_id", secret: "your_secret" });
const object = await sigwise.objects.get("user-42");
const page = await sigwise.objects.list({ q: "is_scammer >= 90", sort: "flagged" });
```

Python:

```python
from sigwise import SigWise

sigwise = SigWise(api_key="your_key_id", secret="your_secret")
obj = sigwise.objects.get("user-42")
page = sigwise.objects.list(q="is_scammer >= 90", sort="flagged")
```

Go:

```go
client := sigwise.New("your_key_id", "your_secret")
obj, err := client.Objects.Get(ctx, "user-42")
page, err := client.Objects.List(ctx, &sigwise.ListObjectsParams{Q: sigwise.String("is_scammer >= 90")})
```

PHP:

```php
$sigwise = new SigWise\Client('your_key_id', 'your_secret');
$object = $sigwise->objects->get('user-42');
$page = $sigwise->objects->list(['q' => 'is_scammer >= 90', 'sort' => 'flagged']);
```

Ruby:

```ruby
require "sigwise"

sigwise = SigWise::Client.new("your_key_id", "your_secret")
object = sigwise.objects.get("user-42")
page = sigwise.objects.list(q: "is_scammer >= 90", sort: "flagged")
```

Each generated package has a README with installation, configuration, error
handling, webhook verification and a reference of every method.

## Other languages

Anything that can compute an HMAC-SHA256 can call the API. See
[Authentication](https://sigwise.ai/docs/guide/authentication.md) for signing examples, and point any
OpenAPI tool at the [specification](https://sigwise.ai/docs/guide/openapi.md).
