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_xyz/sdk
2

Instantiate the class

Instantiate the ParagraphAPI class.
import { ParagraphAPI } from "@paragraph_xyz/sdk"

const api = new ParagraphAPI()
3

Query data

Query Paragraph data. All calls can be found in the SDK repo or on our API reference.
const slug = 'blog'
const publication = await api.getPublicationBySlug(slug)
console.log(`Fetched publication: ${publication}`)

const postData = await api.getPosts(publication.id)
const posts = postData.items

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