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

@villdyr/domeneshop-js

v0.2.0

Published

A zero-dependency TypeScript client for the Domeneshop API — manage domains, DNS records, HTTP forwards, and invoices.

Readme

domeneshop-js

npm version License: MIT

A zero-dependency TypeScript client for the Domeneshop API. Manage domains, DNS records, HTTP forwards, dynamic DNS, and invoices.

  • Zero runtime dependencies (uses native fetch)
  • Full TypeScript support with discriminated union types for DNS records
  • Supports both ESM and CommonJS
  • Covers the complete Domeneshop API v0

Installation

npm install @villdyr/domeneshop-js

Quick Start

import { DomeneshopClient } from "@villdyr/domeneshop-js";

const client = new DomeneshopClient({
  token: "YOUR_API_TOKEN",
  secret: "YOUR_API_SECRET",
});

// List all your domains
const domains = await client.listDomains();

// Add a DNS record
const { id } = await client.createDnsRecord(domains[0].id, {
  host: "www",
  type: "A",
  data: "1.2.3.4",
});

Generate API credentials at domeneshop.no/admin?view=api.

API Reference

Constructor

new DomeneshopClient({ token, secret, baseUrl? })

| Option | Type | Description | | --------- | -------- | ------------------------------------------------------------------ | | token | string | Required. API token. | | secret | string | Required. API secret. | | baseUrl | string | Override the base URL. Defaults to https://api.domeneshop.no/v0. |

Domains

// List all domains (optionally filter by name)
const domains = await client.listDomains();
const filtered = await client.listDomains({ domain: "example.no" });

// Get a single domain
const domain = await client.getDomain(domainId);

DNS Records

Supported record types: A, AAAA, ANAME, CAA, CNAME, DS, MX, NS, SRV, TLSA, TXT.

// List all records for a domain
const records = await client.listDnsRecords(domainId);

// Filter by host and/or type
const aRecords = await client.listDnsRecords(domainId, {
  host: "www",
  type: "A",
});

// Create a record (ttl is optional, defaults to 3600)
const { id } = await client.createDnsRecord(domainId, {
  host: "www",
  type: "A",
  data: "1.2.3.4",
  ttl: 300,
});

// Create an MX record
await client.createDnsRecord(domainId, {
  host: "@",
  type: "MX",
  data: "mail.example.no",
  priority: 10,
});

// Create an SRV record
await client.createDnsRecord(domainId, {
  host: "_sip._tcp",
  type: "SRV",
  data: "sip.example.no",
  priority: 10,
  weight: 60,
  port: 5060,
});

// Get, update, or delete a record
const record = await client.getDnsRecord(domainId, recordId);
await client.updateDnsRecord(domainId, recordId, { host: "www", type: "A", data: "5.6.7.8" });
await client.deleteDnsRecord(domainId, recordId);

Dynamic DNS

// Update DDNS (creates the record if it doesn't exist)
await client.updateDynDns({ hostname: "home.example.no" });

// Specify an IP explicitly
await client.updateDynDns({ hostname: "home.example.no", myip: "1.2.3.4" });

HTTP Forwards

// List forwards
const forwards = await client.listForwards(domainId);

// Create a 301 redirect
await client.createForward(domainId, {
  host: "www",
  frame: false,
  url: "https://example.com",
});

// Get, update, or delete a forward
const forward = await client.getForward(domainId, "www");
await client.updateForward(domainId, "www", { host: "www", frame: false, url: "https://new.example.com" });
await client.deleteForward(domainId, "www");

Invoices

// List all invoices (past 3 years)
const invoices = await client.listInvoices();

// Filter by status: "unpaid" | "paid" | "settled"
const unpaid = await client.listInvoices({ status: "unpaid" });

// Get a single invoice
const invoice = await client.getInvoice(invoiceId);

Error Handling

All API errors throw a DomeneshopError with the HTTP status code and response body:

import { DomeneshopClient, DomeneshopError } from "@villdyr/domeneshop-js";

try {
  await client.getDomain(999);
} catch (error) {
  if (error instanceof DomeneshopError) {
    console.error(error.status); // e.g. 404
    console.error(error.body);   // parsed response body
  }
}

TypeScript

All types are exported for direct use:

import type {
  Domain,
  DomainServices,
  DnsRecord,
  DnsRecordA,
  DnsRecordMX,
  DnsRecordSRV,
  DnsRecordData,
  HttpForward,
  Invoice,
} from "@villdyr/domeneshop-js";

DNS records use discriminated unions — narrow by the type field:

const records = await client.listDnsRecords(domainId);

for (const record of records) {
  switch (record.type) {
    case "A":
      console.log(record.data); // IPv4 address
      break;
    case "MX":
      console.log(record.data, record.priority);
      break;
    case "SRV":
      console.log(record.data, record.priority, record.weight, record.port);
      break;
  }
}

License

MIT