|
1 | | -# Paladins.js |
| 1 | +# paladins.js |
2 | 2 |   |
3 | 3 |
|
4 | 4 | Paladins.js is a package that helps Hi-Rez/Paladins developers communicate with the API. |
5 | 5 |
|
| 6 | +## 2.0 |
| 7 | +v2.0 is a complete rewrite of the current paladins.js library. It is not backwards compatible with any version prior. |
| 8 | + |
| 9 | +Differences between 1.x / 2.x: |
| 10 | +- The complicated cache process has been redone |
| 11 | +- You can pass through more options |
| 12 | +- Proper error handling |
| 13 | +- Returns promises with proper JSON |
| 14 | +- and more... |
| 15 | + |
6 | 16 | ## Install |
7 | 17 | ``` |
8 | 18 | $ npm install paladins.js |
9 | 19 | ``` |
10 | 20 |
|
11 | | -## Cache Driver |
12 | | -A cache driver is **highly** recommended. If there is no driver, it will create a new session on each request. This will make it so that your usage limits are hit within no time. |
13 | | - |
14 | | -We use [cache-driver](https://www.npmjs.com/package/cache-driver) to provide flexibility in what kind of caching system you would like to use, as long as it's an implementation of `cache-driver` then it will work out of the box. |
15 | | - |
16 | 21 | ## Usage |
17 | 22 | *The following examples are in TypeScript, which this package is written in.* |
18 | 23 |
|
19 | | -For the usage example's we'll be using [cache](https://www.npmjs.com/package/cache). We also need the `cache-driver` adapter for `cache` which is [here](https://www.npmjs.com/package/cache-driver-cache) |
20 | | - |
21 | | -``` |
22 | | -$ npm install cache cache-driver-cache |
23 | | -``` |
24 | | - |
25 | 24 | ```javascript |
26 | | -import API from "paladins.js"; |
27 | | -import { CacheAdapter } from "cache-driver-cache"; |
28 | | - |
29 | | -let api = new API("devId", "auhtKey", new CacheAdapter()); // API loaded and ready to go. |
30 | | - |
31 | | -api.getItems().then((response: any) => { |
32 | | - // Do something with response |
33 | | -}); |
| 25 | +import API from 'paladins.js'; |
| 26 | + |
| 27 | +let api = new API({ |
| 28 | + devId: '1234', |
| 29 | + authKey: 'abcd1234' |
| 30 | +}); // API loaded and ready to go. |
| 31 | + |
| 32 | +api.getDataUsage() |
| 33 | + .then((response: any) => { |
| 34 | + // Do something with response |
| 35 | + }) |
| 36 | + .catch((err: any) => { |
| 37 | + // Handle the error |
| 38 | + }); |
34 | 39 | ``` |
35 | 40 |
|
36 | 41 | ## Documentation / Methods |
37 | | -You can view all the available methods and documentation on the [PaladinsDev website](https://paladins.dev/docs/paladins.js/v/1.1.0/). |
| 42 | +You can view all the available methods and documentation on the [PaladinsDev website](https://paladins.dev/docs/paladins.js/v/2.0.0/). |
0 commit comments