Skip to main content
The Paragraph SDK is a typescript wrapper around our REST API. All functionality in the SDK can be found in the API Reference, in the repository on GitHub, or in the documentation on NPM.

Getting started

Follow these steps to install & use the Paragraph typescript SDK.
Prerequisites:
  • Node.js version 19 or higher
1

Install the Paragraph SDK

npm i @paragraph-com/sdk
2

Instantiate the class

Instantiate the ParagraphAPI class.
import { ParagraphAPI } from "@paragraph-com/sdk"

// For public endpoints (no API key required)
const api = new ParagraphAPI()

// For protected endpoints (API key required)
const apiWithAuth = new ParagraphAPI({ apiKey: "your-api-key" })
3

Query data

Query Paragraph data. All calls can be found in the SDK repo or on our API reference.
// Fetch a publication by slug (use .single() for single object)
const publication = await api.publications.get({ slug: "@blog" }).single()
console.log(`Fetched publication: ${publication}`)

// Fetch posts (paginated list)
const { items: posts, pagination } = await api.posts.get({ publicationId: publication.id })

console.log(`Fetched ${posts.length} posts from @blog, out of ${pagination.total} posts: ${JSON.stringify(posts)}`)