Typed clients, an open spec and a server for agents
Every repository is on GitHub under PacketExchangeIO.
Node.js and TypeScript
packetexchange for Node.js 18+, Bun, Deno and modern browsers.
Install
npm install packetexchange- A typed method for every endpoint, returning typed data
- No runtime dependencies: it uses the platform fetch
- ESM, CommonJS and type declarations, prebuilt
- PacketExchangeError with status, code, field details and request id
- Idempotency keys, headers and an AbortSignal on any call
- Cursor pagination, or an async iterator that follows it for you
- verifyWebhookSignature for signed webhook deliveries
Quick start
import { PacketExchange, PacketExchangeError } from 'packetexchange';
const px = new PacketExchange({ apiKey: process.env.PACKETEXCHANGE_API_KEY });
try {
// Send a code by SMS (or channel: 'voice'), then check what the user typed.
const v = await px.verify.start({ to: '+447700900123', channel: 'sms', brand: 'Acme' });
const check = await px.verify.check({ verificationId: v.verificationId, code: '482913' });
console.log(check.status); // approved, denied, expired or max_attempts
// Send an SMS. The idempotency key makes a retry safe.
const sms = await px.comms.sms(
{ to: '+447700900123', from: 'Acme', body: 'Your order 1042 has shipped.' },
{ idempotencyKey: 'order-1042-shipped' },
);
console.log(sms.messageId, sms.status, sms.cost);
} catch (err) {
if (err instanceof PacketExchangeError) console.error(err.status, err.code, err.requestId);
else throw err;
}Money fields are 6-decimal USD strings. SMS status is the send-time outcome, not a handset receipt.
Python
packetexchange for Python 3.9 or later, built on httpx.
Install
pip install packetexchange- Models and operations generated from the OpenAPI document
- Every documented endpoint reachable, with or without a convenience method
- A context manager that closes its connections
- PacketExchangeError with status, code, details and request_id
- Idempotency keys on the calls that send, dial or buy
- The same webhook signature helper as the Node SDK
Quick start
import os
from packetexchange import PacketExchange, PacketExchangeError
with PacketExchange(api_key=os.environ["PACKETEXCHANGE_API_KEY"]) as px:
try:
# Send a code by SMS (or channel="voice"), then check what the user typed.
v = px.verify.start("+447700900123", channel="sms", brand="Acme")
check = px.verify.check(v["verificationId"], "482913")
print(check["status"]) # approved, denied, expired or max_attempts
# Send an SMS. from is a Python keyword, so the sender is from_.
sms = px.comms.sms(
to="+447700900123",
from_="Acme",
message="Your order 1042 has shipped.",
idempotency_key="order-1042-shipped",
)
print(sms["messageId"], sms["status"], sms["cost"])
except PacketExchangeError as e:
print(e.status, e.code, e.request_id)Money fields are 6-decimal USD strings. SMS status is the send-time outcome, not a handset receipt.
Generate a client, or skip the client
OpenAPI specification
Every endpoint, request, response and error as OpenAPI 3. Import it into your API tools, or generate a typed client for PHP, Go, Java, C#, Ruby or anything else.
curl -o openapi.json https://packetexchange.io/api/v1/docs/jsonPlain HTTP in eight languages
Every quickstart is a complete program in cURL, Node, Python, PHP, Go, Java, C# and Ruby using only the standard HTTP client. The example gallery has longer versions with argument handling.
MCP server for AI agents
A hosted Model Context Protocol server. Point Claude, Cursor, VS Code or Codex at one URL with your key in the Authorization header. Nothing to install or run.
https://packetexchange.io/mcp/httpInstall, add a key, send
Open an account, add credit from $5 and create a key. Install the SDK and send your first request.