@posthubify/node
v0.1.1
Published
Official PostHubify Node.js/TypeScript SDK — zero-dependency client for the /v1 API.
Downloads
21
Readme
@posthubify/node
Official TypeScript/Node SDK for the PostHubify Public API (/v1) — zero dependencies, Node 18+.
import { Posthubify, PosthubifyError } from '@posthubify/node';
const ph = new Posthubify({
apiKey: process.env.POSTHUBIFY_API_KEY!, // dashboard → API Keys (sk_…)
baseUrl: 'https://api.example.com/v1',
});
// Publish a post
const post = await ph.posts.create({
content: 'Hello world 👋',
accountIds: ['<account-id>'],
publish: true,
});
// OTP verification flow
const sent = await ph.otp.send({ senderId: '<sender-row-id>', to: '+905xxxxxxxxx', appName: 'MyApp' });
const result = await ph.otp.verify({ senderId: '<sender-row-id>', to: '+905xxxxxxxxx', code: '123456' });
// result.status: 'approved' | 'rejected' | 'expired' | 'max_attempts_exceeded'
// Branded SMS + delivery tracking (DLR)
const sms = await ph.sms.send({ senderId: '<sender-row-id>', to: '+4477…', text: 'Hi!' });
const status = await ph.sms.get(sms.messageId!); // queued → sent → delivered | delivery_unconfirmed | failed
// Errors are thrown as typed exceptions
try {
await ph.sms.send({ senderId: 'x', to: 'y', text: 'z' });
} catch (e) {
if (e instanceof PosthubifyError) console.error(e.status, e.code, e.message);
}Resources covered: profiles · accounts · posts · media · analytics · validate · webhooks · logs ·
inbox (conversations/messages) · comments · reviews · contacts · sequences · numbers · senders · sms · otp.
Machine-readable definition of the API surface: GET /v1/openapi.json (no auth required). The SDK's
correctness is guaranteed by the contract tests in apps/server/src/sdk-contract.test.ts (which connect
to the real server implementation) and by the route↔spec consistency test in openapi.test.ts.
