@pixelstackai/client
v0.1.0
Published
Client library to interact with the Pixelstack API
Maintainers
Readme
@pixelstackai/client
The JavaScript client for Pixelstack. It builds image URLs for your designs and signs them with your team's signing secret.
Signing happens locally: the client makes no network calls. It works in Node.js, edge runtimes and the browser, but keep your signing secret on the server.
Install
npm install @pixelstackai/clientUsage
import { PixelstackClient } from '@pixelstackai/client';
// Reads PIXELSTACK_TEAM_ID and PIXELSTACK_SIGNING_SECRET from the environment
const pixelstack = new PixelstackClient();
const url = pixelstack.getImageUrl('my-design', {
data: { title: { text: 'Hello World' } },
variables: { 'profile-url': 'https://example.com/ada' },
});data sets values on the design's objects, by object ID and property.
variables sets the variables of the design's workflow, by variable ID, the way $variable-id URL parameters do. Objects and arrays are sent as JSON, for json variables. Variables you leave out keep their default value.
Options
new PixelstackClient({
teamId: 'your-team-id', // defaults to PIXELSTACK_TEAM_ID
signingSecret: '...', // defaults to PIXELSTACK_SIGNING_SECRET; URLs are signed when set
});Find your team ID and signing secret in Team settings in the Pixelstack app.
Signing a URL you built yourself
const signedUrl = pixelstack.signUrl('https://cdn.pixelstack.io/your-team-id/my-design?title.text=Hello');Documentation
See docs.pixelstack.io, including the signed URLs guide.
License
MIT
