Tools
TypeScript SDK
Create posts, upload drafts, and read publication data from TypeScript with full type safety.
The SDK is a typed wrapper around the REST API. It needs Node.js 18 or later.
Install
npm i @paragraph-com/sdkCreate a client
Public endpoints work without a key. Pass an API key for anything that writes or reads your own publication.
import { ParagraphAPI } from "@paragraph-com/sdk"
const api = new ParagraphAPI({ apiKey: process.env.PARAGRAPH_API_KEY })Create a post
Posts (articles in the app) publish immediately unless you ask for a draft. Set status: "draft" to review it in the app first, or scheduledAt to publish later.
const { id, status } = await api.posts.create({
title: "What we shipped in October",
markdown: "# October\n\nThree things changed this month.",
status: "draft",
})Update it later with api.posts.update({ id, ... }), and list your drafts with api.posts.list({ status: "draft" }).
Draft an X thread or LinkedIn post
api.content.create puts a short-form draft in the publication's library. Nothing goes out until someone approves it, in the app or with api.content.publish and api.schedule. See Drafted content for every kind and its body.
const draft = await api.content.create({
kind: "tweet",
title: "October launch thread",
body: {
tweets: ["We shipped three things in October.", "Here's the first."],
},
})Read posts
Single results use .single(). Lists return items and cursor-based pagination.
const publication = await api.publications.get({ slug: "@blog" }).single()
const { items, pagination } = await api.posts.get({
publicationId: publication.id,
})
if (pagination.hasMore) {
const next = await api.posts.get({
publicationId: publication.id,
cursor: pagination.cursor,
})
}More
Every method maps to an endpoint in the API reference, which shows SDK examples alongside each one. Releases are on npm.