# TypeScript SDK (/developers/sdk)



The SDK is a typed wrapper around the [REST API](/developers/api-reference). It needs Node.js 18 or later.

## Install [#install]

```bash
npm i @paragraph-com/sdk
```

## Create a client [#create-a-client]

Public endpoints work without a key. Pass an [API key](/developers#authentication) for anything that writes or reads your own publication.

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

const api = new ParagraphAPI({ apiKey: process.env.PARAGRAPH_API_KEY })
```

## Create a post [#create-a-post]

Posts publish immediately unless you ask for a draft. Set `status: "draft"` to review it in the app first, or `scheduledAt` to publish later.

```typescript
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 [#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 sends it from the app. See [Drafted content](/developers/content) for every kind and its body.

```typescript
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 [#read-posts]

Single results use `.single()`. Lists return `items` and cursor-based `pagination`.

```typescript
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 [#more]

Every method maps to an endpoint in the [API reference](/developers/api-reference), which shows SDK examples alongside each one. Source and release notes are on [GitHub](https://github.com/paragraph-xyz/paragraph-sdk-js) and [npm](https://www.npmjs.com/package/@paragraph-com/sdk).
