sdmx-rest
Version:
SDMX REST API client for JavaScript
33 lines (23 loc) • 2.62 kB
Markdown
# sdmx-rest4js
[](https://github.com/sosna/sdmx-rest4js/actions)
[](https://codecov.io/github/sosna/sdmx-rest4js?branch=master)
[](https://www.codefactor.io/repository/github/sosna/sdmx-rest4js)
[](https://snyk.io/test/github/sosna/sdmx-rest4js?targetFile=package.json)
[](https://github.com/semantic-release/semantic-release)
[](https://www.npmjs.com/package/sdmx-rest)
[](http://www.awesomeofficialstatistics.org)
This library allows to easily create and execute [SDMX REST queries](https://github.com/sdmx-twg/sdmx-rest) from a JavaScript client application.
In a nutshell, it allows you to:
- Create [data](https://github.com/sosna/sdmx-rest4js/wiki/Data-queries), [metadata](https://github.com/sosna/sdmx-rest4js/wiki/Metadata-queries) and [data availability queries](https://github.com/sosna/sdmx-rest4js/wiki/Other-queries), using the `getDataQuery`, `getMetadataQuery`, `getAvailabilityQuery` functions;
- Get instances of [SDMX RESTful web services](https://github.com/sosna/sdmx-rest4js/wiki/Services) against which queries can be executed, using the `getService` function;
- [Execute a query](https://github.com/sosna/sdmx-rest4js/wiki/Running-queries) against a web service and get the matching data or metadata, using the `request` function;
- Build [SDMX RESTful URLs](https://github.com/sosna/sdmx-rest4js/wiki/URLs) that represent queries to be executed against SDMX RESTful web services, using the `getUrl` function. This is handy, in case you want to execute the query using, say, jQuery;
The example below shows how a query can be executed against a predefined service using the `request` function.
```JavaScript
var sdmxrest = require('sdmx-rest');
var query = {flow: 'EXR', key: 'A.CHF.EUR.SP00.A'};
sdmxrest.request(query, 'ECB')
.then(function(data) {console.log(data)})
.catch(function(error){console.log("something went wrong: " + error)});
```
For detailed documentation about the API (and more examples), please check the [Wiki](https://github.com/sosna/sdmx-rest4js/wiki).