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

pdns-nodesdk

v0.1.3

Published

A modular client library for interacting with the PowerDNS API.

Readme

PowerDNS Node.js SDK or Simply pdns-nodesdk

A Node.js library for interacting with the PowerDNS API. This SDK simplifies operations with PowerDNS, providing easy-to-use methods for managing servers, zones, cryptokeys, metadata, TSIG keys, and more.

pdns-nodesdk_200x220.png

Whether you're a seasoned developer or just starting out, pdns-nodesdk allows you to seamlessly integrate with PowerDNS, giving you the power to manage DNS zones and configurations programmatically.


Installation

Install the SDK via npm:

npm install pdns-nodesdk

Usage

Setting Up

Import the SDK and initialize it:

import { PdnsNodeSDK } from "pdns-nodesdk";

const apiKey = "your-api-key";
const apiUrl = "http://localhost:8081/api/v1/"; // Update with your PowerDNS API URL

const pdns = new PdnsNodeSDK(apiKey, apiUrl);

Example Use Cases

List All Servers

(async () => {
    const serverList = await pdns.servers.listServers();
    console.log(serverList);
})();

Get Server Information

(async () => {
    const serverId = "localhost";
    const serverInfo = await pdns.servers.getServer(serverId);
    console.log(serverInfo);
})();

Create a New Zone

(async () => {
    const serverId = "localhost";
    const zoneData = {
        name: "example.org.",
        kind: "Master",
        nameservers: ["ns1.example.org.", "ns2.example.org."]
    };

    const newZone = await pdns.zones.createZone(serverId, zoneData);
    console.log(newZone);
})();

Modify Zone RRsets

(async () => {
    const serverId = "localhost";
    const zoneId = "example.org.";
    const rrsetData = {
        rrsets: [
            {
                name: "www.example.org.",
                type: "A",
                ttl: 3600,
                changetype: "REPLACE",
                records: [
                    { content: "192.0.2.1", disabled: false }
                ]
            }
        ]
    };

    await pdns.zones.updateZoneRRsets(serverId, zoneId, rrsetData);
})();

Delete a Zone

(async () => {
    const serverId = "localhost";
    const zoneId = "example.org.";

    await pdns.zones.deleteZone(serverId, zoneId);
})();

Create a Cryptokey

(async () => {
    const serverId = "localhost";
    const zoneId = "example.org.";
    const keyData = {
        keytype: "KSK",
        active: true,
        algorithm: "ECDSAP256SHA256",
        bits: 256
    };

    const cryptokey = await pdns.cryptokeys.createKey(serverId, zoneId, keyData);
    console.log(cryptokey);
})();

Flush Cache

(async () => {
    const serverId = "localhost";
    const domain = "example.org.";

    const cacheFlushResult = await pdns.cache.flushCache(serverId, domain);
    console.log(cacheFlushResult);
})();

Advanced Usage

Custom Configuration

You can modify the client’s behavior by passing additional headers or configuring timeouts:

const pdns = new PdnsNodeSDK(apiKey, apiUrl, {
    headers: { "Custom-Header": "value" },
    timeout: 5000 // 5 seconds
});

Error Handling

Handle API errors using try-catch blocks:

(async () => {
    try {
        const serverInfo = await pdns.servers.getServer("invalid-server");
    } catch (error) {
        console.error("Error:", error.message);
    }
})();

Testing

Integration Tests

We encourage the community to contribute more integration test cases to cover additional scenarios. Comprehensive testing ensures the reliability and robustness of this SDK.

Run integration tests for the SDK:

npm run test:integration

Using Docker for Testing

To facilitate integration tests, we provide a Docker setup for spinning up a minimal PowerDNS instance with SQLite as the backend. This container mimics a real PowerDNS server and allows you to test the SDK in a controlled environment.

Start the Docker Container

Use the following command to spin up the container:

npm run start:docker:test

This command starts a container with PowerDNS configured to use an SQLite database. The configuration includes an example zone to ensure the tests run smoothly.

Stop the Docker Container

After running your tests, clean up by stopping the container:

npm run stop:docker:test

Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue for bugs or feature requests.


License

This project is licensed under the EUPL v1.2.