SDKs & Libraries
SDKs & Libraries
Postscale provides official SDKs for popular programming languages, plus community-maintained libraries for additional platforms.
Official SDKs
Node.js / TypeScript
npm install @postscale/sdk
# or
yarn add @postscale/sdk
# or
pnpm add @postscale/sdk
Usage:
import { Postscale } from '@postscale/sdk';
const postscale = new Postscale('ps_live_your_api_key');
// Send an email
const result = await postscale.emails.send({
from: 'hello@yourapp.com',
to: ['user@example.com'],
subject: 'Welcome!',
html_body: '<h1>Hello World</h1>',
});
console.log('Email sent:', result.message_id);
Features:
- Full TypeScript support with types for all endpoints
- Promise-based async/await API
- Automatic retries with exponential backoff
- Request/response logging for debugging
Python
pip install postscale
# or
poetry add postscale
Usage:
from postscale import Postscale
client = Postscale(api_key='ps_live_your_api_key')
# Send an email
result = client.emails.send(
from_email='hello@yourapp.com',
to=['user@example.com'],
subject='Welcome!',
html_body='<h1>Hello World</h1>'
)
print(f'Email sent: {result.message_id}')
Features:
- Python 3.8+ support
- Type hints for IDE autocomplete
- Sync and async clients available
- Automatic retry handling
Go
go get github.com/postscale/postscale-go
Usage:
package main
import (
"context"
"fmt"
"github.com/postscale/postscale-go"
)
func main() {
client := postscale.NewClient("ps_live_your_api_key")
result, err := client.Emails.Send(context.Background(), &postscale.SendEmailParams{
From: "hello@yourapp.com",
To: []string{"user@example.com"},
Subject: "Welcome!",
HtmlBody: "<h1>Hello World</h1>",
})
if err != nil {
panic(err)
}
fmt.Printf("Email sent: %s\n", result.MessageID)
}
Features:
- Idiomatic Go API design
- Context support for cancellation
- Structured error types
- Connection pooling
Ruby
gem install postscale
# or add to Gemfile
gem 'postscale'
Usage:
require 'postscale'
client = Postscale::Client.new(api_key: 'ps_live_your_api_key')
result = client.emails.send(
from: 'hello@yourapp.com',
to: ['user@example.com'],
subject: 'Welcome!',
html_body: '<h1>Hello World</h1>'
)
puts "Email sent: #{result.message_id}"
PHP
composer require postscale/postscale-php
Usage:
<?php
use Postscale\Client;
$client = new Client('ps_live_your_api_key');
$result = $client->emails->send([
'from' => 'hello@yourapp.com',
'to' => ['user@example.com'],
'subject' => 'Welcome!',
'html_body' => '<h1>Hello World</h1>',
]);
echo "Email sent: " . $result->message_id;
HTTP API
If there's no SDK for your language, you can use the HTTP API directly:
curl -X POST https://api.postscale.io/v1/send \
-H "Authorization: Bearer ps_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"from": "hello@yourapp.com",
"to": ["user@example.com"],
"subject": "Welcome!",
"html_body": "<h1>Hello World</h1>"
}'
SDK Configuration
All SDKs support common configuration options:
| Option | Description | Default |
|---|---|---|
apiKey | Your Postscale API key | Required |
baseUrl | API base URL | https://api.postscale.io |
timeout | Request timeout in ms | 30000 |
retries | Number of retry attempts | 3 |
debug | Enable debug logging | false |
Example (Node.js):
const postscale = new Postscale('ps_live_your_api_key', {
timeout: 60000,
retries: 5,
debug: true,
});
Community Libraries
Community-maintained libraries (not officially supported):
| Language | Library | Maintainer |
|---|---|---|
| Rust | postscale-rs | Community |
| Java | postscale-java | Community |
| .NET | Postscale.NET | Community |
| Elixir | postscale_ex | Community |
Want to build an SDK for another language? Check our API Reference and reach out to get listed here.
Webhooks
The SDKs above focus on the request side of the API. Webhook signature
verification on the receiver side is a small piece of standard-library
HMAC code in any language — see the Webhooks
guide for runnable Node and Python
verifiers, plus details on the timestamped t=…,v1=… format and how to
handle multiple v1= signatures during a rotation grace window.