|
| 1 | +# MC-Market's Official JS API Wrapper |
| 2 | +[](https://github.com/Majored/mcm-js-api-wrapper/blob/main/LICENSE) |
| 3 | +[](https://www.npmjs.com/package/mcm-js-api-wrapper) |
| 4 | + |
| 5 | +An official asynchronous JavaScript (Node.js) wrapper for MC-Market's [Ultimate REST API](https://www.mc-market.org/wiki/ultimate-api/). |
| 6 | + |
| 7 | +* Fully asynchronous design compatible with .then() notation or async/await. |
| 8 | +* Dynamically stalls requests when a rate limit is hit. |
| 9 | +* A comprehensive set of usage examples. |
| 10 | +* Heavily commented making contributions painless. |
| 11 | + |
| 12 | +## Installation & Basic Usage |
| 13 | +Install via `npm`: |
| 14 | +``` |
| 15 | +npm i mcm-js-api-wrapper |
| 16 | +``` |
| 17 | + |
| 18 | +Initialise wrapper and fetch information about yourself via Promise's .then() notation: |
| 19 | +```JS |
| 20 | +const wrapper = require("mcm-js-api-wrapper"); |
| 21 | +const token = {type: "Private", value: "xXoIjvQ6G8UmUPufZWxN-Kkyd54Js_bY"}; |
| 22 | + |
| 23 | +wrapper.init(token).then(init => { |
| 24 | + if (init.result === "error") { |
| 25 | + console.log(init.error); |
| 26 | + process.exit(0); |
| 27 | + } |
| 28 | +}).then(wrapper.members.self().then(self => { |
| 29 | + console.log(self); |
| 30 | +})); |
| 31 | +``` |
| 32 | + |
| 33 | +Initialise wrapper and fetch information about yourself via async/await: |
| 34 | +```JS |
| 35 | +const wrapper = require("mcm-js-api-wrapper"); |
| 36 | +const token = {type: "Private", value: "xXoIjvQ6G8UmUPufZWxN-Kkyd54Js_bY"}; |
| 37 | +... |
| 38 | + |
| 39 | +let init = await wrapper.init(token); |
| 40 | +if (init.result === "error") { |
| 41 | + console.log(init.error); |
| 42 | + process.exit(0); |
| 43 | +} |
| 44 | + |
| 45 | +console.log(await wrapper.members.self()); |
| 46 | +``` |
| 47 | + |
| 48 | +A full list of functions and their signatures can be found [here](https://github.com/MC-Market-org/mcm-js-api-wrapper/blob/main/USAGE.md). |
| 49 | + |
| 50 | +## Issues & Support |
| 51 | +The [issues tracker](https://github.com/MC-Market-org/mcm-js-api-wrapper/issues) for this repository should only be used to report bugs or issues with this official JS wrapper. |
| 52 | + |
| 53 | +For bugs or issues related to the Ultimate API itself, please open a [support ticket](https://www.mc-market.org/tickets/new) or create a [bug report](https://www.mc-market.org/suggestions/create-thread) on our platform. |
0 commit comments