@qurl/api-client
v0.1.1
Published
TypeScript client for the QURL Developer API (/api/v1)
Maintainers
Readme
@qurl/api-client
TypeScript client for the QURL Developer API (/api/v1).
Install
From the QURL monorepo:
{
"dependencies": {
"@qurl/api-client": "workspace:*"
}
}External consumers: copy packages/qurl-api-client or publish to your registry when available.
Usage
import { QurlApiClient, QurlApiError } from "@qurl/api-client";
const client = new QurlApiClient({
baseUrl: process.env.QURL_API_BASE_URL!,
token: process.env.QURL_API_TOKEN!,
});
const { data: me } = await client.getMe();
console.log(me.plan, me.token.scopes);
const { data: qr, rateLimit } = await client.createQrCode(
{
title: "Flyer",
destinationUrl: "https://example.com/flyer",
externalId: "flyer-001",
},
{ idempotencyKey: "flyer-001-create" },
);
console.log(qr.shortUrl, qr.images.png);
if (rateLimit) console.log("remaining", rateLimit.remaining);
try {
await client.updateQrCode(qr.id, { destinationUrl: "https://example.com/new" });
} catch (e) {
if (e instanceof QurlApiError) {
console.error(e.code, e.requestId, e.details);
}
}Methods
| Method | API route |
|--------|-----------|
| getMe() | GET /me |
| listQrCodes(query?) | GET /qr-codes |
| createQrCode(body, opts?) | POST /qr-codes |
| getQrCode(id) | GET /qr-codes/{id} |
| updateQrCode(id, body) | PATCH /qr-codes/{id} |
| archiveQrCode(id) | DELETE /qr-codes/{id} |
| getQrCodeImage(id, opts?) | GET /qr-codes/{id}/image |
| getQrCodeAnalytics(id, query?) | GET /qr-codes/{id}/analytics |
| batchQrAnalytics(body) | POST /qr-codes/batch/analytics |
| getApiUsage() | GET /api-usage |
OpenAPI
Contract: openapi/qurl-api-v1.yaml · Live: GET /api/v1/openapi
Build
npm run build -w @qurl/api-client
npm run test -w @qurl/api-client