Skip to content

paragraph-xyz/paragraph-sdk-js

Repository files navigation

@paragraph-com/sdk

TypeScript SDK for the Paragraph API. Used to interact with Paragraph posts, users, coins, & more.

Install

yarn add @paragraph-com/sdk

Quick start

import { ParagraphAPI } from "@paragraph-com/sdk";

// For public endpoints
const api = new ParagraphAPI();
const post = await api.posts.get({ id: "postId" });

// For protected endpoints (creating posts, managing subscribers)
const apiWithAuth = new ParagraphAPI({ apiKey: "your-api-key" });
const newPost = await apiWithAuth.posts.create({
  title: "My Post",
  markdown: "# Hello World",
});

Authenticated endpoints

Several endpoints require an API key, which identifies your publication. Pass it when creating the client:

const api = new ParagraphAPI({ apiKey: "your-api-key" });

// Get your publication info
const publication = await api.me.get();

// List your drafts
const { items: drafts } = await api.posts.list({ status: "draft" });

// Update a post
await api.posts.update({
  id: "postId",
  title: "Updated Title",
  markdown: "## New content",
  status: "published",
});

// Delete a post
await api.posts.delete({ id: "postId" });

Documentation

See the API reference for detailed documentation & a playground.

See autogenerated TypeScript docs for all available methods.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors