Skip to content
pushqdocs
Get started

pushq has official SDKs for TypeScript/JavaScript, Python, Go, Java and .NET. Each one is a thin, typed wrapper over the REST API. They cover every queue and task endpoint and include a helper to verify signed deliveries. This page covers what is the same everywhere: installing, creating a client, client options, errors, pagination and signature verification. The rest of the docs show every example in all five languages, plus curl.

Parameter tables across the docs use the API’s JSON field names, such as rate_limits.max_dispatches_per_second. Each SDK uses its own language’s casing for those names. See Naming conventions.

npm install pushq
  • TypeScript: pnpm add pushq and bun add pushq work too. In Deno, import npm:pushq.
  • Go: the import path ends in /go, so import the package with an explicit name: import pushq "github.com/blissfulrays/pushq/sdks/go".
  • Java: the SDK is not on Maven Central yet; that is coming. Until then, mvn install builds it and puts it in your local Maven repository (~/.m2). Then add the dependency:
<dependency>
<groupId>io.github.blissfulrays</groupId>
<artifactId>pushq</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

The Maven group is io.github.blissfulrays, but the Java package is io.pushq.

Create an API key in the console (see API keys) and pass it to the client. With no base URL, every SDK talks to the hosted API at https://api.pushqueue.dev.

import { Pushq } from "pushq";
const pq = new Pushq({ apiKey: process.env.PUSHQ_API_KEY });

The SDKs send the key as Authorization: Bearer <key>. None of them reads environment variables on its own, so pass the key in explicitly. Every SDK exports the default URL as a constant: DEFAULT_BASE_URL in TypeScript and Python, pushq.DefaultBaseURL in Go, Pushq.DEFAULT_BASE_URL in Java and PushqClient.DefaultBaseUrl in .NET.

Create one client and reuse it. The Go, Java and .NET clients are documented as safe to share across threads and goroutines.

Pass your server’s URL. If you run pushq dev locally, which has no API keys, leave the key out. Every SDK then sends no Authorization header.

import { Pushq } from "pushq";
const pq = new Pushq({ baseUrl: "https://pushq.internal.example.com", apiKey: process.env.PUSHQ_API_KEY });
// `pushq dev`: no key needed
const local = new Pushq({ baseUrl: "http://localhost:8080" });

Every SDK strips trailing slashes from the base URL. An empty or whitespace-only base URL falls back to the hosted API.

Apart from the base URL and API key, the SDKs let you set a request timeout and, in most of them, supply your own HTTP client:

import { Pushq } from "pushq";
const pq = new Pushq({
baseUrl: "https://api.pushqueue.dev",
apiKey: process.env.PUSHQ_API_KEY,
timeoutMs: 10_000, // per request; default 30_000
fetch: async (input, init) => {
// custom fetch: logging, tracing, proxies, tests
const res = await fetch(input, init);
console.log(init?.method, String(input), res.status);
return res;
},
});
SDK Timeout Custom HTTP client Notes
TypeScript timeoutMs, default 30000 fetch (defaults to the global fetch) The constructor throws if no fetch is available.
Python timeout (seconds), default 30.0 client=httpx.Client(...), or httpx.AsyncClient for AsyncPushq When you pass client, the SDK ignores base_url, api_key and timeout; set them on the httpx client. close() also closes a client you passed in.
Go from the http.Client, default 30 s pushq.WithHTTPClient(hc) This replaces the whole client. Per-call deadlines come from the context.Context that every method takes first.
Java timeout(Duration), default 30 s not supported The SDK uses its own java.net.http.HttpClient and does not follow redirects.
.NET Timeout, default 30 s HttpClient Timeout is ignored when you supply HttpClient. The SDK never disposes an HttpClient you supply. Every method takes an optional CancellationToken.

None of the SDKs retries failed API calls. If you add retries, set a task_id on every task you create. A retried create then fails with already_exists instead of enqueueing the task twice.

The SDKs follow their language’s conventions, so the same call looks different in each:

TypeScript Python Go Java .NET
Create a task createTask create_task CreateTask createTask CreateTaskAsync
Batch create createTasks create_tasks CreateTasks createTasks CreateTasksAsync
Queue stats queueStats queue_stats QueueStats queueStats GetQueueStatsAsync
Fields camelCase (maxDispatchesPerSecond) snake_case (max_dispatches_per_second) PascalCase (MaxDispatchesPerSecond) camelCase builder methods and getters PascalCase properties
Building input object literals keyword arguments and config classes (RateLimits, Retry, Target) structs; optional numbers are pointers (pushq.Int(3), pushq.Float64(3600)) builders (TaskCreate.builder()...build()) object initializers
Sync or async all methods return a Promise Pushq (sync) and AsyncPushq (async) blocking; ctx first synchronous ...Async methods
Timestamps Date datetime time.Time Instant DateTimeOffset
Raw body (body_base64) body: string | Uint8Array body: bytes Body []byte body(byte[]) Body (byte[])
Delay and deadline seconds (delaySeconds) seconds seconds (*float64) seconds TimeSpan (Delay, DispatchDeadline)
Task type Task Task pushq.Task Task PushqTask

Every SDK base64-encodes raw bodies for you, so you never build body_base64 yourself. Queue names that contain /, such as user/instagram, are URL-encoded automatically. See queue folders.

Every non-2xx API response becomes an error that carries the HTTP status, a stable machine-readable code, and a human-readable detail. Branch on code, not on the message text.

import { PushqError } from "pushq";
try {
await pq.createTask("emails", { taskId: "welcome-user-42", path: "/hooks/send-welcome" });
} catch (err) {
if (err instanceof PushqError && err.code === "already_exists") {
// already enqueued: nothing to do
} else if (err instanceof PushqError) {
console.error(err.status, err.code, err.detail);
throw err;
} else {
throw err; // timeout or network error
}
}

Over raw HTTP, errors come back as RFC 9457 application/problem+json, and the SDKs read the same fields:

{
"type": "about:blank",
"title": "Conflict",
"status": 409,
"code": "already_exists",
"detail": "...",
"instance": "/v1/queues/emails/tasks"
}

The error reference lists every code, its HTTP status and what to do about it.

API errors and transport failures (timeouts, refused connections, DNS) surface differently:

SDK API error Transport failure Invalid input caught before sending
TypeScript PushqError (status, code, detail) DOMException named TimeoutError on timeout; otherwise what fetch throws (TypeError) Error when both body and jsonBody are set
Python PushqError (status, code, detail) httpx exceptions, such as httpx.TimeoutException and httpx.ConnectError ValueError when both body and json_body are set
Go *pushq.Error (Status, Code, Detail); test with pushq.IsCode(err, code) the net/http or context error, unwrapped none
Java unchecked PushqException (getStatus(), getCode(), getDetail()) PushqException with getStatus() == 0; the cause holds the IOException IllegalStateException from TaskCreate.build() for conflicting fields
.NET PushqException (Status, Code, Detail) HttpRequestException or TaskCanceledException ArgumentException for conflicting fields

If an error response is not a problem document, for example an HTML page from a proxy, the code is internal in TypeScript, Python, Go and .NET. In Java it is null. In every SDK, detail holds the response body, which may be truncated.

list queues and list tasks return one page at a time with a next_page_token. Pass it back as page_token to get the next page, and keep the other parameters the same. The last page has no token. Page size defaults to 100 and is capped at 1000. None of the SDKs has an auto-paging iterator, so loop until the token is empty:

let pageToken: string | undefined;
do {
const page = await pq.listTasks("emails", { state: "failed", pageSize: 1000, pageToken });
for (const task of page.items) console.log(task.id);
pageToken = page.nextPageToken;
} while (pageToken);

Task lists are returned newest first, and queue lists in name order. Listing queues needs an admin API key.

When a queue has a target.signing_secret, pushq signs every delivery using the Standard Webhooks scheme, with webhook-id, webhook-timestamp and webhook-signature headers. Each SDK ships a verifier. Use it in the endpoint that receives tasks, and reject the request with 401 if verification fails. Delivery explains the headers and the signing scheme.

Always verify the raw request body, exactly as it arrived. If a framework parses the JSON first and you re-serialize it, the bytes can differ and verification fails.

import express from "express";
import { verifySignature, WebhookVerificationError } from "pushq";
const app = express();
// express.raw keeps the body as an unparsed Buffer; don't run express.json() on this route.
app.post("/hooks/send-welcome", express.raw({ type: "*/*" }), async (req, res) => {
const payload: Buffer = Buffer.isBuffer(req.body) ? req.body : Buffer.alloc(0);
let webhookId: string;
try {
webhookId = await verifySignature({
secret: process.env.PUSHQ_SIGNING_SECRET!,
headers: req.headers,
payload,
});
} catch (err) {
if (err instanceof WebhookVerificationError) return res.sendStatus(401);
throw err;
}
const { userId } = JSON.parse(payload.toString("utf8"));
// ... do the work, using webhookId as an idempotency key ...
res.sendStatus(204);
});

The webhook-id has the form <queue>/<task_id>, for example emails/welcome-user-42, and stays the same on every retry of a task. Use it as an idempotency key to skip work you have already done. Respond with a 2xx status once the work succeeds. Any other status, or no response before the dispatch deadline, counts as a failed attempt and is retried.

Other frameworks:

  • TypeScript (Fetch API runtimes: Hono, Cloudflare Workers, Next.js route handlers, Deno, Bun): pass payload: new Uint8Array(await request.arrayBuffer()) and headers: request.headers. In Hono, use c.req.raw.headers.
  • Python: in Flask, pass request.headers, request.get_data(). In Django, pass request.headers, request.body in a @csrf_exempt view.
  • Go: chi handlers are plain http.HandlerFuncs and work unchanged. In gin, read c.GetRawData() and c.Request.Header before any ShouldBindJSON.
  • Java (plain Servlet): read req.getInputStream().readAllBytes() and the three headers with req.getHeader(...).
  • .NET (MVC controllers): read Request.Body the same way, and don’t declare a [FromBody] parameter.

Here is each verifier with all of its arguments, including the timestamp tolerance:

import { verifySignature } from "pushq";
const webhookId: string = await verifySignature({
secret: "whsec_dGVzdC1zZWNyZXQ=", // "whsec_<base64>" or a raw string
headers: request.headers, // Headers or a plain object
payload: rawBody, // string | Uint8Array, exactly as received
toleranceSeconds: 300, // default 300; 0 disables the timestamp check
now: new Date(), // optional, for tests
});
SDK Returns Default tolerance Failure
TypeScript Promise<string> (the webhook-id) 300 s rejects with WebhookVerificationError
Python str (the webhook-id) 300 s raises WebhookVerificationError
Go (string, error) none, you pass it error wrapping pushq.ErrVerification
Java void (read the id from the header) none, you pass it throws unchecked WebhookVerificationException
.NET string (the webhook-id) 5 minutes (Webhooks.DefaultTolerance) throws WebhookVerificationException

In every SDK:

  • A secret that starts with whsec_ is base64-decoded after the prefix. Any other string is used as raw UTF-8 key bytes.
  • The tolerance applies in both directions, to timestamps in the past and in the future.
  • The signature header may contain several space-separated v1,<signature> entries. Verification passes if any of them matches, and the comparison is constant-time.

Every SDK also exports a sign function (sign, pushq.Sign, Webhooks.sign, Webhooks.Sign). It produces a v1,<base64> signature so you can test your endpoint without a pushq server.

SDK Package Requires Notes
TypeScript npm pushq Node.js 18.17+, Bun, Deno, Cloudflare Workers and other runtimes with fetch ESM and CommonJS builds with type declarations; no runtime dependencies. Server-side only: it would expose your API key in a browser, and the API sends no CORS headers.
Python PyPI pushq Python 3.9+ Depends only on httpx>=0.25. Ships type hints (py.typed). Sync Pushq and async AsyncPushq.
Go github.com/blissfulrays/pushq/sdks/go Go 1.22+ Every method takes a context.Context.
Java io.github.blissfulrays:pushq (build from source for now) Java 11+ Synchronous and thread-safe. Depends on jackson-databind and jackson-datatype-jsr310. JPMS module name io.pushq.
.NET NuGet Pushq netstandard2.0 (.NET Framework 4.6.2+, .NET Core, .NET 5+) and net10.0 No dependencies on net10.0. On netstandard2.0 it pulls in System.Text.Json.

The SDKs wrap queue and task operations only. To create, list or revoke API keys, manage team members, or read the server version (GET /v1/version), use the console or call the REST API directly. See API keys and Team members.