npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shopnex/payload-sdk

v3.1.7

Published

The official Payload REST API SDK

Downloads

449

Readme

Here's a professional and well-structured README.md for your Payload SDK:


Payload SDK

A fully type-safe SDK for interacting with the Payload CMS REST API. This package simplifies working with Payload by offering a seamless, strongly typed developer experience—closely mirroring the Local API interface.

✨ Features

  • 🔒 Full Type Safety – powered by your generated Payload types.
  • 🔁 Support for all core operations – including collections, globals, auth, versions, and file uploads.
  • 🔍 Query filters & population – type-safe where, select, and populate support.
  • 📁 File uploads – simplified with native Blob, File, or URL input.
  • 🧩 Custom endpoints – easy access to non-standard REST routes.
  • ⚙️ Custom fetch and request config – extend or replace fetch logic and share common options.

🚀 Installation

npm install @payloadcms/sdk
# or
pnpm add @payloadcms/sdk

🛠️ Usage

import { PayloadSDK } from "@payloadcms/sdk";
import type { Config } from "./payload-types";

const sdk = new PayloadSDK<Config>({
    baseURL: "https://example.com/api",
});

✅ Core Operations

Find Documents

const posts = await sdk.find({
    collection: "posts",
    draft: true,
    limit: 10,
    locale: "en",
    page: 1,
    where: { _status: { equals: "published" } },
});

Find by ID

const post = await sdk.findByID({
    collection: "posts",
    id,
    draft: true,
    locale: "en",
});

Count Documents

const result = await sdk.count({
    collection: "posts",
    where: { id: { equals: post.id } },
});

Create Document

const result = await sdk.create({
    collection: "posts",
    data: { text: "hello" },
});

Create with File Upload

const result = await sdk.create({
    collection: "media",
    file, // File | Blob | string (URL)
    data: {},
});

Update Document by ID

const result = await sdk.update({
    collection: "posts",
    id: post.id,
    data: { text: "updated" },
});

Bulk Update

const result = await sdk.update({
    collection: "posts",
    where: { id: { equals: post.id } },
    data: { text: "bulk-updated" },
});

Delete by ID

const result = await sdk.delete({
    collection: "posts",
    id: post.id,
});

Bulk Delete

const result = await sdk.delete({
    collection: "posts",
    where: { id: { equals: post.id } },
});

🌐 Global Operations

await sdk.findGlobal({ slug: "global" });
await sdk.updateGlobal({ slug: "global", data: { text: "updated" } });

🔐 Auth Operations

// Login
await sdk.login({
    collection: "users",
    data: { email: "[email protected]", password: "123456" },
});

// Me
await sdk.me(
    { collection: "users" },
    {
        headers: { Authorization: `JWT ${token}` },
    }
);

// Refresh Token
await sdk.refreshToken(
    { collection: "users" },
    {
        headers: { Authorization: `JWT ${token}` },
    }
);

// Forgot Password
await sdk.forgotPassword({
    collection: "users",
    data: { email: "[email protected]" },
});

// Reset Password
await sdk.resetPassword({
    collection: "users",
    data: { token, password: "new-password" },
});

🕓 Versions

await sdk.findVersions({
    collection: "posts",
    where: { parent: { equals: post.id } },
});

await sdk.findVersionByID({
    collection: "posts",
    id: version.id,
});

await sdk.restoreVersion({
    collection: "posts",
    id,
});

// Global Versions
await sdk.findGlobalVersions({ slug: "global" });
await sdk.findGlobalVersionByID({ slug: "global", id: version.id });
await sdk.restoreGlobalVersion({ slug: "global", id });

🧩 Custom Requests

await sdk.request({
    method: "POST",
    path: "/send-data",
    json: { id: 1 },
});

⚙️ Custom Fetch + Shared Init

const sdk = new PayloadSDK<Config>({
    baseURL: "https://example.com/api",
    baseInit: {
        credentials: "include",
    },
    fetch: async (url, init) => {
        console.log("Request started");
        const response = await fetch(url, init);
        console.log("Request completed");
        return response;
    },
});

📘 Notes

  • All operations support a third optional parameter to customize fetch options (headers, etc.).
  • Fully compatible with RequestInit, enabling cookies, custom headers, CORS config, and more.

📄 License

MIT – © 2025 Payload CMS contributors


Let me know if you'd like me to publish this to npm, generate a tsdoc documentation site, or help integrate into your CI/CD!