Socket
Book a DemoInstallSign in
Socket

hetzner-dns-client

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hetzner-dns-client

Hetzner DNS API client for Node.js

1.1.3
latest
Source
npmnpm
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

Node.js Hetzner DNS API Client

Hetzner DNS API Version Version Downloads

Hetzner DNS API client for Node.js

Installation

npm i hetzner-dns-client

Usage

You can use this client library with your Node.js project.

JavaScript Example

import {HetznerDnsClient, DnsRecord} from 'hetzner-dns-client';

// create client instance
const client = new HetznerDnsClient("YOUR_API_TOKEN");
// get zone by ID
const zone = await client.zones.get("ZONE_ID");
// create apex/root zone record of type "A" to 127.0.0.1
const record = await zone.createRecord("@", DnsRecord.Type.A, "127.0.0.1");

TypeScript Example

import {HetznerDnsClient, DnsRecord, Zone} from 'hetzner-dns-client';

// create client instance
const client: HetznerDnsClient = new HetznerDnsClient("YOUR_API_TOKEN");
// get zone by ID
const zone: Zone = await client.zones.get("ZONE_ID");
// create apex/root zone record of type "A" to 127.0.0.1
const record: DnsRecord = await zone.createRecord("@", DnsRecord.Type.A, "127.0.0.1");

Handling Errors

Methods that may throw an error are marked with throws in the documentation and specify what error types may be thrown. You can catch these errors with a try/catch block.

For example:

try {
    const zone = await client.zones.get("ID that does not exist");
}
catch (err) {
    if (err instanceof ApiError)
        console.error(err); // the Hetzner API returned an error, e.g. "Zone not found"
    else if (err instanceof ClientParseError)
        console.error(err); // the client could not understand or parse the response from the Hetzner API
    else
        console.error(err); // some other error occurred
}

API Documentation

The official Hetzner DNS API documentation can be found on https://dns.hetzner.com/api-docs/.

Note: The Hetzner DNS API documentation appears to be incomplete and contains a few errors. The documentation of this client library is a separate documentation and some functionality may be described differently.

If you find any errors in the documentation, or think that further clarification is needed, please open an issue or pull request.

The client library documentation is available in DOCS.md in this repository.

Keywords

client

FAQs

Package last updated on 25 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.