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 🙏

© 2024 – Pkg Stats / Ryan Hefner

novaposhta

v1.1.1

Published

Javascript module to interact with NovaPoshta API

Downloads

211

Readme

Novaposhta

Version Downloads/week License

A small library that provides a helper class to work with Nova Poshta API.

Usage

Install it using the following command:

npm i novaposhta

The library exports the NovaPoshta class that you need to use to make requests to API. You need to instantiate an instance of the class providing an object with configuration options. The instance of the class has getters that allows you to get access to a specific model of the APIs.

Also, please, pay attention that some API methods require API key for authorization. You can obtain it by going to this page.

Here is a basic example that shows how to use the library:

import NovaPoshta from 'novaposhta';

const api = new NovaPoshta({ apiKey: '...' });

api.address
    .getCities({ Ref: "ebc0eda9-93ec-11e3-b441-0050568002cf" })
    .then((json) => {
        // do something
    })
    .catch((errors) => {
        if (Array.isArray(errors)) {
            errors.forEach((error) => console.log(`[${ error.code || '-' }] ${ error.en || error.uk || error.ru || error.message }`));
        }
    });

A bit more advanced example that demonstrates how you can configure a Winston Logger and use it with the library:

import NovaPoshta from 'novaposhta';
import Winston from 'winston';
import WinstonFormatter from 'winston-console-formatter';

const winstonLogger = new Winston.Logger({ level: "debug" });
winstonLogger.add(Winston.transports.Console, WinstonFormatter.config());

const api = new NovaPoshta({
    apiKey: '...',
    logger: winstonLogger,
});

api.address.getCities({ Ref: "ebc0eda9-93ec-11e3-b441-0050568002cf" }).then((json) => {
	// do something
});

Supported API Methods

Address

const api = new NovaPoshta({ apiKey: '...' });

api.address.getCities({ Ref: "ebc0eda9-93ec-11e3-b441-0050568002cf" }).then((json) => {
    // do something
});

Common

const api = new NovaPoshta({ apiKey: '...' });

api.common.getTimeIntervals({ "RecipientCityRef": "8d5a980d-391c-11dd-90d9-001a92567626" }).then((json) => {
    // do something
});

Counterparty

const api = new NovaPoshta({ apiKey: '...' });

api.counterparty.getCounterpartyContactPersons({ ... }).then((json) => {
    // do something
});

ContactPerson

const api = new NovaPoshta({ apiKey: '...' });

api.contactPerson.save({ ... }).then((json) => {
    // do something
});

Internet Document

const api = new NovaPoshta({ apiKey: '...' });

api.internetDocument.getDocumentList({ ... }).then((json) => {
    // do something
});

ScanSheet

const api = new NovaPoshta({ apiKey: '...' });

api.scanSheet.getScanSheetList({ ... }).then((json) => {
    // do something
});

AdditionalService

const api = new NovaPoshta({ apiKey: '...' });

api.additionalService.getReturnOrdersList({ ... }).then((json) => {
    // do something
});

AdditionalServiceGeneral

const api = new NovaPoshta({ apiKey: '...' });

api.additionalServiceGeneral.checkPossibilityForRedirecting({ ... }).then((json) => {
    // do something
});

Contribute

Want to help or have a suggestion? Open a new ticket and we can discuss it or submit a pull request. Please, make sure you run npm test before submitting a pull request.

License

MIT