skosmos-api-client

1.0.0 • Public • Published

Skosmos API client NPM Version Build Status Test Coverage

Javascript client for accessing services using Skosmos, like Finto. The client provides a Promise-based interface and uses the HTTP REST API of Skosmos behind the scenes.

Usage

AS OF NOW, ONLY A FEW SKOSMOS METHODS ARE IMPLEMENTED BY THIS MODULE

The module returns a factory function that takes a single argument which is an object. The object has a mandatory property url which denotes the URL of the Skosmos endpoint. The factory function returns an object with the following methods:

  • vocabularies (lang): Returns an array of vocabulary objects (/vocabularies)
  • vocabulary (name, lang): Returns an object which contains information about the vocabulary name (/<vocid>/)
    • lookup (name, label, lang): Searches label from vocabulary name. Returns an array of label objects (/<vocid>/lookup)

Node.js

var skosmos_client = require('skosmos-api-client/lib/nodejs')({
  url: 'https://api.finto.fi/rest/v1'
});
 
return skosmos_client.vocabulary.lookup('yso', 'cat', 'en').then(function(result) {
  // Do something with the result
});

AMD

define(['skosmos-api-client/lib/browser'], function(skosmosClientFactory) {
 
  var skosmos_client = skosmosClientFactory({
    url: 'https://api.finto.fi/rest/v1'
  });
 
  return skosmos_client.vocabulary.lookup('yso', 'cat', 'en').then(function(result) {
    // Do something with the result
  });
 
});
 

Development

Clone the sources and install the package using npm:

npm install

Run the following NPM script to lint, test and check coverage of the code:

 
npm run check
 

License and copyright

Copyright (c) 2016-2017 University Of Helsinki (The National Library Of Finland)

This project's source code is licensed under the terms of MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i skosmos-api-client

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • natlibfi-arlehiko