GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - NicTool/api: NicTool API v3

BranchesTags
Open more actions menu

Latest commit

 

History

63 Commits
63 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.release @ 290b441
.release @ 290b441
 
 
conf.d
conf.d
 
 
docker
docker
 
 
html
html
 
 
lib
lib
 
 
routes
routes
 
 
sql
sql
 
 
test
test
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
.prettierignore
.prettierignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTORS.md
CONTRIBUTORS.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
eslint.config.mjs
eslint.config.mjs
 
 
package.json
package.json
 
 
server.js
server.js
 
 

Repository files navigation

Build Status Coverage Status

NicTool API v3

A RESTful JSON web service that exposes DNS management functions to users.

Install

  1. Install Node.js
  2. Download the NicTool v3 API
mkdir nictool && cd nictool
git clone https://github.com/NicTool/api.git
cd api
npm install

Configure

Edit the files in conf.d to reflect your local settings.

Each config file has a default section which lists all available config settings. Below the default section are optional deployment environments such as production, development, and test. When a deployment environment is detected, overrides in the matching deployment section are applied.

Start the service

Running one of these commands:

npm run start (production)

or

npm run develop (development)

will start up the HTTP service on the port specified in conf.d/http.yml. The default URL for the service is http://localhost:3000 and the API methods have documentation at http://localhost:3000/documentation#/.

Using the API service

Until the NicTool 3.0 HTTP client is written, using a web browser (in Developer mode) or a CLI HTTP utility like curl can be used. Here's a quick tutorial:

Start a New Session

curl -X POST http://localhost:3000/session

{ "statusCode": 400, "error": "Bad Request", "message": "Invalid request payload input" }

The request was rejected because it's missing the required parameters, as shown in the documentation. Create a file called nt-auth.json and store the credentials of a NicTool user therein, with the username qualified by the user's group name:

{ "username": "[email protected]", "password": "Wh@tA-Decent#P6ssw0rd" }

Then try the auth request again:

curl -X POST http://localhost:3000/session --header "Content-Type: application/json" -d @nt-auth.json | json_pp

{
  "group": {
    "id": 4096,
    "name": "example.com"
  },
  "meta": {
    "api": {
      "version": "3.0.3"
    },
    "msg": "you are logged in"
  },
  "session": {
    "id": 1,
    "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ1cm46YXVkaWVuY2U6dGVzdCIs..."
  },
  "user": {
    "email": "[email protected]",
    "first_name": "Unit",
    "id": 4096,
    "is_admin": false,
    "last_name": "Test",
    "username": "unit-test"
  }
}

session.token is a JWT, valid for 8 hours. Send it as a Bearer token in the Authorization header of every other request. With jq, save it to a shell variable:

TOKEN=$(curl -s -X POST http://localhost:3000/session --header "Content-Type: application/json" -d @nt-auth.json | jq -r .session.token)

and then use it:

curl -s http://localhost:3000/user/4096 --header "Authorization: Bearer $TOKEN" | json_pp
{
  "group": {
    "id": 4096
  },
  "meta": {
    "api": {
      "version": "3.0.3"
    },
    "msg": "here's your user"
  },
  "user": [
    {
      "deleted": false,
      "email": "[email protected]",
      "first_name": "Unit",
      "id": 4096,
      "inherit_group_permissions": true,
      "is_admin": false,
      "last_name": "Test",
      "permissions": { "...": "..." },
      "username": "unit-test"
    }
  ]
}

Without the header, the API answers 401:

{ "statusCode": 401, "error": "Unauthorized", "message": "Missing authentication" }

About

NicTool API v3

www.npmjs.com/package/@nictool/api

Topics

dns-managementnictool

Resources

Readme
BSD-3-Clause license

Security policy

Security policy
Activity
Custom properties

Stars

1 star

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.