SDKs & Libraries
Official SDKs for Node.js, Python, PHP, and Ruby to integrate Postject into your application.
Node.js / TypeScript
Full TypeScript support with comprehensive type definitions for all API endpoints.
Installation
npm install postject-sdk
# or
yarn add postject-sdk
# or
pnpm add postject-sdkQuick Start
import { Postject } from 'postject-sdk';
const client = new Postject({
apiKey: 'pk_live_your_api_key_here',
});
// Send an email
const result = await client.send({
to: 'customer@example.com',
subject: 'Welcome!',
html: '<h1>Welcome to our platform</h1>',
});
console.log('Message ID:', result.id);Examples
Send with Template:
await client.sendWithTemplate(
'template_id',
'user@example.com',
{
name: 'John Doe',
orderNumber: '12345',
}
);Manage Webhooks:
// Create webhook
const webhook = await client.createWebhook(
'stream_id',
'https://yourapp.com/webhook',
['delivered', 'bounced']
);
// Get delivery logs
const { logs, total } = await client.getWebhookLogs('webhook_id', {
limit: 50,
});Content Analysis:
const analysis = await client.analyzeContent(
'Subject line',
'<html>Email content</html>'
);
console.log('Spam score:', analysis.spamScore);
console.log('Overall score:', analysis.overallScore);
console.log('Issues:', analysis.issues);Full documentation: npmjs.com/package/postject-sdk
Python
Pythonic SDK with full type hints (Pydantic models) and async support.
Installation
pip install postjectQuick Start
from postject import Postject
client = Postject(api_key="pk_live_your_api_key_here")
# Send an email
result = client.send({
"to": "customer@example.com",
"subject": "Welcome!",
"html": "<h1>Welcome to our platform</h1>"
})
print(f"Message ID: {result.id}")Examples
Type-Safe Requests:
from postject import SendEmailRequest
request = SendEmailRequest(
to="user@example.com",
subject="Order Confirmation",
html="<p>Your order has been confirmed</p>",
tags=["order", "confirmation"],
metadata={"order_id": "12345"}
)
result = client.send(request)Async Support:
import asyncio
from postject import AsyncPostject
async def send_email():
async with AsyncPostject(api_key="your_key") as client:
result = await client.send({
"to": "user@example.com",
"subject": "Async Email",
"html": "<p>Sent asynchronously</p>"
})
print(f"Sent: {result.id}")
asyncio.run(send_email())Context Manager:
with Postject(api_key="your_key") as client:
result = client.send({
"to": "user@example.com",
"subject": "Test",
"html": "<p>Email body</p>"
})
# Client automatically closedFull documentation: pypi.org/project/postject
SDK Features
Full API Coverage
Send emails, manage servers, streams, templates, webhooks, and more.
Automatic Retries
Built-in retry logic for rate limits with configurable attempts.
Type Safety
Full TypeScript definitions (Node.js) and Pydantic models (Python).
Performance
Optimized HTTP clients with connection pooling and timeouts.
Error Handling
Both SDKs provide specific error classes for different scenarios:
import {
PostjectError,
AuthenticationError,
RateLimitError,
ValidationError,
} from 'postject-sdk';
try {
await client.send({ /* ... */ });
} catch (error) {
if (error instanceof RateLimitError) {
console.log('Rate limited. Retry after:', error.retryAfter);
} else if (error instanceof ValidationError) {
console.log('Invalid request:', error.response);
}
}Need Help?
Having trouble with the SDK? We're here to help.
Email us at support@postject.com or check the API documentation for more details.