Wrap Royale Core
Wrap royale core is a promise based, minimalist wrapper for the official Clash Royale REST API. It covers all endpoints and parameters, but it barely offers any utility methods. If you are looking for a more feature rich library to interact with the Clash Royale API, take a look at wrap-royale which utilizes this library.
Official Clash Royale API documentation: https://developer.clashroyale.com
- Lightweight, promise based wrapper functions for API requests.
- Types for all returned JSON data, which makes working with it very handy due to intellisense (see: https://i.imgur.com/xzP1AHC.png).
- Normalizes player tags, no matter if you pass
#20ppthe request will succeed.
- Failed requests (wrong https status code in response or timeout exceeded) throw an exception
- All API endpoints and parameters are covered.
- Node.js 8.0+
- Token for the official Clash Royale API (register here and create a token for your IP address https://developer.clashroyale.com)
$ npm install --save wrap-royale-core
Note: Typescript definitions are included, there is no need for installing types from the Definetely Typed Repo.
const CRApi = CRApi;const baseUri = '';const apiToken = 'my-long-jwt';const api = baseUri apiToken;api
The class CRApi offers all available endpoints as promise based functions. Each function returns a Promise which resolves to the json response from the API. If the HTTPS response code is not 2xx (for instance
503 which is being used for API maintenance) an exception will be thrown.
When creating a CRApi instance you can pass the following options:
/*** Initialize all settings.* @param uri Base url to Clash Royale API e.g. ''.* @param token Your API token (JWT as string).* @param options Additional options for this wrapper.*/constructoruri: string, token: string, options?: IApiOptions;
Below you'll find a summary of all available methods. For more details about the parameters or method, take a look at the code which comes along with function documentation.