# SDKs

> Official SDKs for Node.js, Python, Go, Ruby, PHP, Rust, Java, and .NET — plus a CLI, and a clean REST API for everything else.

SendPing ships **official SDKs for eight languages** — Node.js ([`sendping`](https://www.npmjs.com/package/sendping) on npm), Python, Go, Ruby, PHP, Rust, Java, and .NET — plus a [CLI](https://www.sendping.co/docs/resources/cli). Each wraps the same REST API with the idioms of its ecosystem.

Underneath them all is a **clean REST API**: predictable request and response shapes, `mb_`-prefixed API keys, the `Bearer` auth scheme, a consistent error envelope, and standard pagination conventions. So every language has two good options: install the official SDK, or hit the JSON API directly with any HTTP client.

## Official Node.js SDK

Install the `sendping` package and instantiate the client with your `mb_` API key. Every method returns `{ data, error }` — `error` is `null` on success, or `{ statusCode, name, message }` on failure, so there are no exceptions to catch for API errors.

```bash
npm install sendping
```

**Send an email**

```ts
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.emails.send({
  from: 'Acme <hello@yourdomain.com>',
  to: ['delivered@test.sendping.co'],
  subject: 'Hello from SendPing',
  html: '<p>Your first email 🎉</p>',
});

if (error) console.error(error.name, error.message);
else console.log('sent', data.id);
```

The client exposes one property per resource — `emails` (with nested `emails.receiving`), `batch`, `domains`, `audiences`, `contacts`, `contactProperties`, `campaigns`, `segments`, `topics`, `templates`, `automations`, `webhooks`, `logs`, `events`, `apiKeys`, and `polls` — each modeled on the same `create` / `get` / `list` / `update` shape used throughout these docs.

**Override the API host**

```ts
const mb = new SendPing('mb_xxxxxxxxx', {
  baseUrl: 'https://www.sendping.co/api', // optional — defaults to the SendPing host
});
```

> **Note:** The same client ships for Python (`pip install sendping`), Ruby (`gem install sendping`), PHP (`composer require sendping/sendping`), Rust (`cargo add sendping`), .NET (`dotnet add package SendPing`), Go, and Java — see [SDKs & CLI](https://www.sendping.co/sdks) for every package manager command.

## Call the REST API directly

Every endpoint in these docs is plain JSON over HTTPS at `https://www.sendping.co/api`. Authenticate with an `Authorization: Bearer mb_xxxxxxxxx` header. Each API page shows ready-to-run snippets for every official SDK plus raw **cURL**.

**Node.js**

```js
import { SendPing } from 'sendping';

const mb = new SendPing('mb_xxxxxxxxx');

const { data, error } = await mb.emails.send({
  "from": "Acme <hello@yourdomain.com>",
  "to": ["delivered@test.sendping.co"],
  "subject": "Hello from SendPing",
  "html": "<p>It works!</p>"
});
console.log({ data, error });
```

**Ruby**

```ruby
require "sendping"

SendPing.api_key = "mb_xxxxxxxxx"

SendPing::Emails.send({
  "from": "Acme <hello@yourdomain.com>",
  "to": [
    "delivered@test.sendping.co"
  ],
  "subject": "Hello from SendPing",
  "html": "<p>It works!</p>"
})
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

use SendPing\SendPing;

$sendping = SendPing::client('mb_xxxxxxxxx');

$sendping->emails->send([
  'from' => "Acme <hello@yourdomain.com>",
  'to' => [
    "delivered@test.sendping.co"
  ],
  'subject' => "Hello from SendPing",
  'html' => "<p>It works!</p>"
]);
```

**Python**

```python
import sendping

sendping.api_key = "mb_xxxxxxxxx"

sendping.Emails.send({
  "from": "Acme <hello@yourdomain.com>",
  "to": [
    "delivered@test.sendping.co"
  ],
  "subject": "Hello from SendPing",
  "html": "<p>It works!</p>"
})
```

**Go**

```go
import "github.com/shekhu10/sendping-sdks/sendping-go"

client := sendping.NewClient("mb_xxxxxxxxx")

sent, err := client.Emails.Send(&sendping.SendEmailRequest{
    From:    "Acme <hello@yourdomain.com>",
    To:      []string{"delivered@test.sendping.co"},
    Subject: "Hello from SendPing",
    Html:    "<p>It works!</p>",
})
```

**Rust**

```rust
use sendping::{SendEmailOptions, SendPing};

let mb = SendPing::new("mb_xxxxxxxxx");

let params = SendEmailOptions::new(
    "Acme <hello@yourdomain.com>",
    ["delivered@test.sendping.co"],
    "Hello from SendPing",
)
.with_html("<p>It works!</p>");
let _sent = mb.emails.send(params).await?;
```

**Java**

```java
import co.sendping.SendPing;
import co.sendping.SendPingResponse;
import co.sendping.requests.SendEmailRequest;

SendPing sendping = new SendPing("mb_xxxxxxxxx");

SendEmailRequest request = SendEmailRequest.builder()
        .from("Acme <hello@yourdomain.com>")
        .to("delivered@test.sendping.co")
        .subject("Hello from SendPing")
        .html("<p>It works!</p>")
        .build();

SendPingResponse response = sendping.emails().send(request);
```

**.NET**

```csharp
using SendPing;

ISendPing sendping = SendPingClient.Create("mb_xxxxxxxxx");

var resp = await sendping.EmailSendAsync(new EmailMessage
{
    From = "Acme <hello@yourdomain.com>",
    To = "delivered@test.sendping.co",
    Subject = "Hello from SendPing",
    HtmlBody = "<p>It works!</p>",
});
```

**cURL**

```bash
curl -X POST 'https://www.sendping.co/api/emails' \
  -H 'Authorization: Bearer mb_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
  "from": "Acme <hello@yourdomain.com>",
  "to": ["delivered@test.sendping.co"],
  "subject": "Hello from SendPing",
  "html": "<p>It works!</p>"
}'
```

**CLI**

```bash
sendping emails send \
  --from 'Acme <hello@yourdomain.com>' \
  --to 'delivered@test.sendping.co' \
  --subject 'Hello from SendPing' \
  --html '<p>It works!</p>'
```

> **Note:** Official SDKs ship for Go, Ruby, PHP, Python, Rust, Java, and .NET. The Java artifact is a zero-dependency JVM jar, so Kotlin and Scala projects add the same `co.sendping:sendping` coordinate. Android is the exception: the default transport uses `java.net.http` (Java 11+), which Android does not ship, so an Android app must supply its own `HttpTransport` implementation. Any other language with an HTTP client (Elixir, …) can call the API directly.

## Any HTTP client works

Prefer no dependency? The API is plain JSON over HTTPS, so the standard HTTP client in any language can call it directly. Point your client at `https://www.sendping.co/api` with your `mb_` key and send a request:

- **Node.js** — the official `sendping` SDK, or the built-in `fetch`.
- **PHP** — the official `sendping/sendping` package, or Guzzle / the cURL extension.
- **Python** — the official `sendping` package, or `requests` / `httpx`.
- **Ruby** — the official `sendping` gem, or `Net::HTTP` / `Faraday`.
- **Go** — the official Go module, or `net/http`.
- **Java** — the official `co.sendping:sendping` artifact, or `java.net.http.HttpClient`.
- **Rust** — the official `sendping` crate, or `reqwest`.
- **.NET** — the official `SendPing` NuGet package, or `HttpClient`.

Each API reference page includes ready-to-run snippets for every official SDK — Node.js, Ruby, PHP, Python, Go, Rust, Java, .NET, the CLI — plus raw cURL, so your stack's tab is one click away.

## Which should I use?

| You have… | Use |
| --- | --- |
| A Node.js / TypeScript project | Install the official `sendping` SDK. |
| A Python, Go, Ruby, PHP, Rust, Java, or .NET project | Install the official SDK for that language — see [SDKs & CLI](https://www.sendping.co/sdks). |
| Anything else with an HTTP client | Call the REST API directly. |
| A framework that only speaks SMTP | Use an HTTPS-capable adapter. Raw SMTP is not currently deployed. |
