puckCloud
Create a Puck Cloud client. Its requests use the API key, host and auth given here.
import puckCloud from "@puckeditor/cloud-client";
// or: const puckCloud = require("@puckeditor/cloud-client");
const puck = puckCloud(process.env.PUCK_API_KEY);
const page = await puck.pages.get("page_123");Returns a client.
Args
| Param | Example | Type | Status |
|---|---|---|---|
config | "SECRET" | String | Object | - |
config
An API key, or the API key, host and auth to use, as options.
Options
| Param | Example | Type | Status |
|---|---|---|---|
apiKey | apiKey: "SECRET" | String | - |
auth | auth: { tenantId: "team-1" } | Object | - |
host | host: "https://www.example.com/api" | String | - |
apiKey
The API key to send with each request. Defaults to the PUCK_API_KEY environment variable.
const puck = puckCloud({
apiKey: process.env.MY_PUCK_KEY,
});auth
The tenant to use, and the user to attribute changes to. Takes the same tenantId and identity as puckHandler.
const puck = puckCloud({
auth: {
tenantId: user.teamId,
identity: { id: user.id, name: user.name },
},
});host
The Puck Cloud host to call. Defaults to the PUCK_HOST environment variable, then Puck Cloud.
const puck = puckCloud({
host: "https://www.example.com/api",
});Returns
Returns an object with the server APIs for each module:
| Param | Example | Type |
|---|---|---|
ai | ai: { generate: () => {} } | Object |
auth | auth: { getSession: () => {} } | Object |
pages | pages: { list: () => {} } | Object |