npm.io
2.1.6 • Published 10 years ago

gw2_api_miniwrapper

Licence
MIT
Version
2.1.6
Deps
2
Vulns
6
Weekly
0
Stars
3

GuildWars 2 API Wrapper

Lightweight, simple to use GuildWars 2 API Wrapper

Version

2.1.6

Added Browser support (webpack / browserify)

How to Install
npm i gw2_api_miniwrapper --save

To transpile / test:

git clone https://github.com/mievstac/gw2_api_miniwrapper.git
cd gw2_api_miniwrapper
npm install

Transpile Es6 --> Es5

npm install -g gulp
cd gw2_api_miniwrapper
gulp default
How to use

In depth Wiki: https://github.com/mievstac/gw2_api_miniwrapper/wiki

ES 6

import gw2Api from 'gw2_api_miniwrapper';

gw2Api({
    endpoints: 'items'
}).then(function (items) {
    console.log(items);
}).catch(function (error) {
    console.log(error);
});

ES 5

var gw2Api = require('./index').default;

gw2Api({
    endpoints: 'items'
}).then(function (items) {
    console.log(items);
}).catch(function (error) {
    console.log(error);
});
Examples
import gw2Api from 'gw2_api_miniwrapper';

gw2Api({ // get All items
    endpoints: 'items'
}).then(function (items) {
    console.log(items);
}).catch(function (error) {
    console.log(error);
});

gw2Api({ // get items 1 and 2
    endpoints: 'items',
    ids: [1, 2]
}).then(function (items) {
    console.log(items);
}).catch(function (error) {
    console.log(error);
});

gw2Api({ //search for recipe input, ID 46731
    endpoints: ['recipes','search'],
    input: '46731' //switch to output: <ID> for output
}).then(function(data){
    console.log(data);
})

gw2Api({  // Account endpoint (apiKey required)
    endpoints: 'account',
    apiKey: 'APIKEY_HERE'
}).then(function (data) {
    console.log(data);
}).catch(function (error) {
    console.log(error);
})


Todos
  • TESTS

License

MIT

Keywords