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

vegvesen

v0.3.1

Published

Node.JS wrapper for Statens Vegvesens NVDB REST APIs

Downloads

28

Readme

vegvesen

NodeJS wrapper for Statens Vegvesen's NVDB REST APIs

Installation

npm install vegvesen

You can also download it manually.

Usage

var VegvesenClient  = require("vegvesen");
var vegvesen = new VegvesenClient();

vegvesen.connect(function(){
    vegvesen.vegobjekter.spesifiktVegobjekt(82559833, function(obj){
        console.log(obj);
    });
});

All methods are loaded dynamically when connect() is called. This is dictated by the specification of the API. So for an up-to-date guide, check the official documentation.

Examples

If the API endpoint url changes, you can provide an optional argument in the constructor

new VegvesenClient("https://api.endpoint.url");

You can also provide an optional options object to change request and response parameters

new VegvesenClient("https://api.endpoint.url", {
    requestConfig: {
     timeout: 1000,
        noDelay: true,
        keepAlive: true
    },
    responseConfig: {
        timeout: 1000 //response timeout 
    }
});

Function names are based off of the "rel" property of each API object. So e.g.

<ressurs rel="spesifikt-vegobjekt" uri="/vegobjekter/objekt/{vegobjekt-id}"/>

can be accessed by calling

vegvesen.vegobjekter.spesifiktVegobjekt();

Some methods requires parameters, theese can be specified like:

vegvesen.vegobjekter.spesifiktVegobjekt(487458622);

In case a method requires multiple parameters, they can be supplied by passing an array containing the arguments, e.g.

vegvesen.vegreferanse.vegreferanseFraWgs84Koordinat([5.26835878197702, 60.38078971681345]});

To access the result of an API call, every method also takes a callback function as the last argument, e.g.

vegvesen.vegobjekter.spesifiktVegobjekt(487458622, function(data){
    console.log(data);
});

More examples can be found under the folder "examples"

Methods

Currently at the time of publishing this version of the module, this is the functions exposed by the API:

definisjoner
  • vegobjektTyper()
  • vegobjektTypeDefinisjon()
  • egenskapsTypeDefinisjon()
  • datakatalogVersjon()
vegobjekter
  • vegobjekterAvGittType()
  • spesifiktVegobjekt()
sokegrensesnitt
  • sok()
vegreferanse
  • vegreferanseFraUtm33Koordinat()
  • vegreferanseFraWgs84Koordinat()
  • vegreferanseFraVeglenke()
  • vegreferanseFraVegreferansenavn()
  • vegreferanse()
  • veglenkeTilVegreferanse()
omrader
  • regioner()
  • vegavdelinger()
  • fylker()
  • politidistrikter()
  • kommuner()
  • riksvegruter()
  • kontraktsomrader()
endringer
  • endringerObjekttype()

Building

In version 0.3.0 build scripts was implemented. In the future, this will make it possible to build a browser compatible version of this client. As of now it isn't working, because there is still some dependencies issues that needs to be worked out. The build script however does work, and can be testet today.

To build node-vegvesen run the following command inside the root directory of the sources:

npm run-script build

This will build a bundled file, and a bundled + minified file under the dist directory. There is also a prepublish hook in the package.json that automatically builds before publishing to npm.

Contributing

Do you want to help me with the development of node-vegvesen? Great! If you would like to contribute to the node-vegvesen project, please check out the contribution guide in CONTRIBUTING.md.

If you don't know how to contribute, but still have some suggestions, please create a new Issue, or contact me directly. Please check out the Contact information for more.

Contact

If you have any questions regarding the usage of this API client, just contact me through the contact information provided on the github repo, and also specified in the npm package.json

Legal

Copyright Thomas Alrek (C) 2016

This module is released as GNU General Public License version 2, see file LICENSE.md for details. You are free to use this in your own applications. However, the data gathered from NVDB is licensed under the NLOD license (Norwegian, English). If you use the data in your application, you are required by this license to always include the following text:

Inneholder data under norsk lisens for offentlige data (NLOD) tilgjengeliggjort av Statens vegvesen.