• TypeScript 98.8%
  • JavaScript 1.2%
Find a file
2026-04-06 02:36:13 -04:00
.github/workflows chore: update publish workflow 2026-04-06 02:31:42 -04:00
lib fix: correctly import package version, fix issues with rollup and typescript 2026-04-06 02:30:36 -04:00
.editorconfig style: add prettier and editorconfig and format entire project accordingly 2025-07-14 19:37:12 +02:00
.gitignore finish up progress, rework build process 2022-11-27 01:06:01 -05:00
.npmignore finish up progress, rework build process 2022-11-27 01:06:01 -05:00
.prettierrc.toml style: add prettier and editorconfig and format entire project accordingly 2025-07-14 19:37:12 +02:00
jest.config.cjs fix(RateLimiter): fix flakey tests 2025-07-14 18:40:46 +02:00
LICENSE Create LICENSE 2021-06-15 22:29:42 -04:00
package-lock.json fix: correctly import package version, fix issues with rollup and typescript 2026-04-06 02:30:36 -04:00
package.json chore: update version 2026-04-06 02:36:13 -04:00
README.md chore: update readme 2022-11-28 22:16:48 -05:00
rollup.config.mjs fix: correctly import package version, fix issues with rollup and typescript 2026-04-06 02:30:36 -04:00
tsconfig-cjs.json finish up progress, rework build process 2022-11-27 01:06:01 -05:00
tsconfig.json fix: get package version for user agent directly from package.json 2026-04-05 23:59:45 -04:00

pkapi.js

A PluralKit API wrapper for NodeJS, written in TypeScript

About

PluralKit is an incredibly useful tool for plurals, trans folks, and roleplayers that comes with an API for use alongside the bot. This wrapper was created to make interacting with the API in Node.js applications easier

This wrapper comes with features like:

  • Full coverage of the API (up to v2)
  • More options for setting values (eg: "red" is a valid member.color)
  • Options to fetch members, fronters, and switches when fetching a system
  • Promise based and object oriented

And more!

Installation

With Node 14.x or higher, use this to install:
npm install pkapi.js

Dependencies

This library uses only a few dependencies, which are:

  • axios - for request handling
  • @vvo/tzdb - for verifying timezones
  • chrono-node - for parsing birthdays
  • tinycolor2 - for parsing colors
  • valid-url - for verifying avatar urls

Setup

The wrapper itself requires zero setup. However, there are still some options you can use:

// cjs, or commonJS
const PKAPI = require('pkapi.js').default;

// esm
import PKAPI from 'pkapi.js';

// shown values are defaults!
const api = new PKAPI({
	base_url: "https://api.pluralkit.me", // base api url
	version: 2, // api version
	token: undefined // for authing requests. only set if you're using this for a single system!
})

Note: This library currently supports up to APIv2.

Examples

Using the above setup; note that exmpl is a real system

// get a system by id
var system = await api.getSystem({system: 'exmpl'});

// authed version of above
var system = await api.getSystem({system: 'exmpl', token: process.env.TOKEN});

// edit the system
system.tz = "est";
system.description = "Test system";

// patch
await system.patch(process.env.TOKEN);

// see the changes
console.log(system)
// get member
var member = await api.getMember({member: 'gaznz'};

// edit
member.name = "Test Name";
member.visibility = true; // public
member.name_privacy = false; // private
await member.patch(process.env.TOKEN)

console.log(member)

Docs

Check out the wiki for documentation