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

porkbun-typescript-sdk

v1.0.0

Published

A type-safe TypeScript SDK for the Porkbun API

Readme

Porkbun TypeScript SDK License: MIT

Overview

This SDK acts as a wrapper around the Porkbun API by way of a PorkbunClient class providing methods for every API endpoint, along with additional helper functions.

This project is not affiliated with or endorsed by Porkbun. Please ask questions or report issues on our issue tracker, not through any official Porkbun channels.

Installation

npm install [PACKAGE NAME HERE]

Quick Start

  1. Ensure your domain is accessible via the API under Domain Management -> Details -> API Access
  2. Create a API key and secret key at https://porkbun.com/account/api
  3. In your project, initialize the PorkbunClient class like so:

[!WARNING] Do not keep your keys in your source code! Use environment variables or some other method of protecting your keys.

import { PorkbunClient } from 'porkbun-typescript-sdk';

const pbClient = new PorkbunClient({
	secretApiKey: 'sk1_12a3b456...',
	apiKey: 'pk1_1234ab56...'
})
  1. Start interacting with the API!
const getAllDomains = async () => {
	const response = await pbClient.domains.listAll();
	console.log(response);
}

/*
{
  status: "SUCCESS",
  domains: [
    {
      domain: "example.com",
      status: "ACTIVE",
      tld: "com",
      createDate: "2025-07-03 02:06:57",
      expireDate: "2026-07-03 02:06:57",
      securityLock: "1",
      whoisPrivacy: "1",
      autoRenew: "1",
      notLocal: 0,
    }, {
      domain: "example.net",
      status: "ACTIVE",
      tld: "net",
      createDate: "2023-07-30 20:25:46",
      expireDate: "2026-07-30 20:25:46",
      securityLock: "1",
      whoisPrivacy: "1",
      autoRenew: "1",
      notLocal: 0,
    }
  ],
}
*/

If you need to change the base URL (defaults to https://api.porkbun.com/api/json/v3), you can pass the baseUrl parameter into the PorkbunClient constructor alongside your API key.

Namespaces

The SDK is broken up into 3 namespaces: domains, dns, and ssl, along with standalone ping() and getDefaultPricing() methods.

Parameters, return types, and examples are documented within the SDK using JSDoc. Hover over any method in your IDE to reveal it.

  • listAll() - Retrieves all domains in the account.
  • checkDomain() - Checks the availability of a domain.
  • getNameservers() - Gets the authoritative name servers listed at the registry for a domain.
  • updateNameservers() - Updates the authoritative name servers listed at the registry for a domain.
  • getUrlForwarding() - Gets a list of URL forwards for a domain.
  • addUrlForward() - Adds a URL forward to a domain.
  • deleteUrlForward() - Deletes a URL forward from a domain.
  • getGlueRecords() - Gets a list of hosts and their glue records for a domain.
  • createGlue() - Creates a glue record for a domain.
  • updateGlue() - Updates a glue record for a domain.
  • deleteGlue() - Deletes a glue record for a domain.
  • getDnsRecords() - Retrieves all DNS records associated with a domain.
  • getDnsRecord() - Retrieves a DNS record by its ID.
  • getRootDnsRecords() - Retrieves all DNS records of a given type at the root domain.
  • getSubdomainDnsRecords() - Retrieves all DNS records of a given type at a specific subdomain.
  • createDnsRecord() - Creates a DNS record on the specified domain.
  • editDnsRecordById() - Edits a DNS record on the specified domain.
  • editDnsRecordsBySubdomain() - Edits all DNS records for a domain that match a particular subdomain and type.
  • deleteDnsRecordById() - Deletes a specific DNS record on a domain.
  • deleteDnsRecordsBySubdomain() - Deletes all DNS records for a domain that match a particular subdomain and type.
  • createDnssecRecord() - Creates a DNSSEC record at the registry.
  • deleteDnssecRecord() - Deletes a DNSSEC record associated with the domain at the registry.
  • getDnssecRecords() - Gets all DNSSEC records at the registry for a specific domain.
  • getSslBundle() - Retrieves the SSL certificate bundle for a domain.

Types

Types are exported for your use and convenience. These include all the payload and response types corresponding to each endpoint, such as RetrieveDnsRecordsPayload and RetrieveDnsRecordsResponse.

Additionally, you have access to these entity types:

  • Domain - A domain in your account with status, dates, and settings.
  • DomainLabel - A label that can be attached to domains for organization.
  • GlueRecord - A glue record mapping a hostname to IP addresses.
  • GlueRecordAddresses - IPv4 and IPv6 addresses for a glue record.
  • DnsRecord - A DNS record with id, name, type, content, TTL, priority, and notes.
  • DnssecRecord - A DNSSEC record with keyTag, algorithm, digestType, and digest.
  • DNS_RECORD_TYPE - Enum of supported DNS record types (A, MX, CNAME, ALIAS, TXT, NS, AAAA, SRV, TLSA, CAA, HTTPS, SVCB, SSHFP).

Contributing

Any kind of good-faith contribution is welcome, no matter how small. For larger contributions that modify the external API the SDK provides - such as adding new helper functions, - consider discussing your idea with us ahead of time in an issue so you don't end up working on something for nothing.

This project uses Bun, a fast JavaScript runtime that acts as a drop-in replacement for Node.js. Please see the Bun website for simple installation instructions.

Clone the repository

git clone https://github.com/maxwellward/porkbun-typescript-sdk.git

Install dependencies

bun install

Build package

To run:

bun run build

Link to a test project

You can use bun link to link the in-development package to another project temporarially to test your changes.

First, run bun link in the root of this project. Then, in the root of your test project, run bun link porkbun-typescript-sdk to install it. Once done, you can simply rebuild the package and the link will automatically update.

Guidelines

  • Ensure all functions have a JSDoc with a description, parameters, and a return tag at least.
  • Return data from the API unmodified (don't change field names).
  • Ensure functions calling the Porkbun API have proper validation using assertValid().
  • Ensure README.md is updated to reflect the changes you make, if needed.

License

This project is licensed under the MIT License.