smartapi-parser

a nodejs library for parsing smartapi specifications

Usage no npm install needed!

<script type="module">
  import smartapiParser from 'https://cdn.skypack.dev/smartapi-parser';
</script>

README

smartapi-parser

Test Coveralls Coverage Status TypeScript npm npm bundle size npm

A NodeJS library for parsing SmartAPI specifications

Install

$ npm install smartapi-parser

Usage

The package requires SmartAPI specification in JSON format as its input. You can use fs or API fetch libraries such as node-fetch, axios to load a SmartAPI file from local or remote desitiniations.

const parser = require('smartapi-parser');
// need to install node-fetch libary first using npm i node-fetch
const fetch = require('node-fetch');

fetch('https://smart-api.info/api/metadata/81955d376a10505c1c69cd06dbda3047')
    .then(response => response.json())
    .then(spec => {
        let api = new parser(spec);
        console.log(api.metadata);
    });
    
    // // {
    // 	"title": "SEMMED Gene API",
    // 	"tags": ["disease", "annotation", "query", "translator", "biothings", "semmed"],
    // 	"url": "https://biothings.ncats.io/semmedgene",
    // 	"operations": [
    // 		"query_operation": ...,
    // 		"association": ...,
    // 		"response_mapping": ...,
    // 		"id": ...
    // 	]
    // // }

Related