instabuilds
Official NPM module for the website https://instabuilds.gg
Works server-side & browser-side.
Installation
npm install --save @league-of-legends-devs/instabuilds
TODO
- Constants
CHAMPION_ROLE
ITEM_SET_TYPE
Examples
const InstaBuilds = require('@league-of-legends-devs/instabuilds');
const client = new InstaBuilds('Application name');
await client.auth.authenticateWithKey('AUTH_KEY');
await client.auth.authenticate('USERNAME', 'PASSWORD');
const reCaptchaSiteKey = await client.recaptcha.getSiteKey();
await client.users.create('RECAPTCHA_AUTH_TOKEN', {
email: 'bestteemona@riotgames.com',
region: 'NA',
login: 'BestTeemoNA',
password: 'SHR0om$_',
thirdPartyCode: 'YOLO',
});
const patchVersion = await client.static.getLastPatchVersion();
const itemSet = {
title: 'My dank Ahri waifu build',
champion: { id: 103 },
role: { id: InstaBuilds.CHAMPION_ROLE.MIDDLE },
maps: [11]
comment: 'Easy build',
content: {
blocks: [{
type: 'First block'
items: [
{ id: 4004, count: 2 }
]
}]
}
};
const uploadedItemSet = await client.itemSets.upload(itemSet);
client.startListeners();
client.events.onDownloadRequest(data => {
});
API (TODO: documentation in active redaction)
InstaBuilds.init(applicationName [, opts])
Initialize and returns a new client.
Params :
applicationName
: String
. The name of your application (e.g.: "My InstaBuilds client").opts
: optional Object
. Options (details coming soon).
Returns :
client.login(authKey)
or client.login(userName, password)
Log in to the https://instabuilds.gg server with either a auth key or an username & password.
This step is required for some features related to user accounts.
client.login()
also starts a micro web sockets client ensuring the server that this client is alive and that it can send signals to it.
Returns :
- a
Promise
:
Object
. null
if failed authentication.
text
: String
. The server response.
client.logout()
Log out the client. The same client can log in again with the client.login()
function.
As client.login()
starts a micro web sockets client ensuring the server that this client is alive, this function stops it.
Returns :
- a
Promise
:
Object
. null
if the client failed to log out.
text
: String
. The server response.
client._setDefaultItemSetsDownloadRoute
(undocumented)
Override the /downloads/sets-from-lib
to /downloads/sets-from-app
. Must be undocumented.
client.startListeners()
Start the Web Socket listeners, which are not activated by default.
This step is required in order to use the client.onMessage()
event listeners.
client.stopListeners()
Stop the Web Socket listeners. These can be restarted later using client.startListeners()
.
TODO: Rewrite client.get(data, [, params], callback)
Requests some datas to the server.
Params :
data
: String. The type of data to request. Refer to the "Available data
inputs" section below.params
: optional Object
. Parameters to give to the data request. Depends on the data
value.callback
: Optional callback function. Executed when the server sent a response. Follows the current schema : function(err, response) {}
. If not set, the get()
method returns a Promise
.
err
: Error
. null
if successful requestresponse
: Object
. The retrieved informations, depending on the data
value. null
if failed request.
Available data
inputs ; each different value will have its own associated response (in the response
argument of the callback) :
'patchVersion'
: Gets the current patch version of the server.
response
: Object
.
version
: String
. Patch version (format : 'X.X.X') of the latest item sets generation. This value can differ from the official patch version, as the server takes a little time to generate the datas for the current patch.generationDate
: Date
. Date of the latest item sets generation.
'news'
: Gets the "news" section : announcements, warnings ...
response
: Object
.
text
: String
. The content of the "news" section.date
: Date
. Date of broadcast.
'itemSets'
: Gets a list of every item sets in a generation. This counts as a download.
params
: Object
.
id
: optional String
. The id of the item sets generaton (format : 'XXXXXXXXXXXXXXXXXXXXXXXX', see the sets page). If null
, get the latest generation.
response
: Object
.
date
: Date
. The generation date of the item sets.itemSets
: [Object]
. List of the item sets, as JSON objects.
'itemSet'
: Gets a single item set. This counts as a download.
params
: Object
.
- Either :
generationId
: String
. The id of the generation (format : 'XXXXXXXXXXXXXXXXXXXXXXXX', see the sets page).itemSetNumber
: String
or Number
- Or :
generationId
: optional String
. The id of the generation (format : 'XXXXXXXXXXXXXXXXXXXXXXXX', see the sets page). If null
, get the latest generation.championKey
: String
. The "key" of the champion (e.g.: "MonkeyKing" for Wukong, "AurelionSol" for Aurelion Sol).
response
: Object
.
date
: Date
. The generation date of the item set.itemSet
: Object
. The item set, as JSON object.type
: String
. The item sets type. Values : 'generated-riot'
, 'generated-probuilts'
, 'custom'
.author
: String
. The author's name of this item set. null
if generated by the server.
'userDatas'
: Gets informations of the current logged in user.
response
: Object
.
username
: String
. User name.lastLogin
: Date
. Date of last login.itemSets
: [Object]]
. List of the user item sets, as JSON objects. Contains all the item sets of the user : generated and custom builds.
Returns :
- if no
callback
provided, returns a Promise
:
Object
. The retrieved informations, depending on the data
value.
client.downloadItemSets(data, [, params], callback)
// TODO
client.send(data, [, params], callback)
// TODO
client.onMessage(data, [, params], action)
// TODO
client.on(data, action)
// TODO
client.submitBug(data, callback)
Params :
data
: Object.
platform
: Integer
. ID of the platform where the bug is located ('Website' : 1, 'Application' : 2 ...).title
: String
. Short description of the bug.content
: String
. Detailed description of the bug.sendAdditionalDatas
: Boolean
. Set to true
to send additional datas to help fix the bug (operation system, default browser and screen resolution).
callback
: Callback function. Executed when the server sent a response. Follows the current schema : function(err) {}
. If not set, the submitBug()
method returns a Promise
.
err
: Error
. null
if failed to submit the bug.
Returns :
- if no
callback
provided, returns a Promise
.
Privacy and conditions
By using this module, you agree to the terms and conditions and privacy policy of https://instabuilds.gg.
License
The MIT License (MIT)
Copyright (c) 2018 Nicolas COUTIN
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Anyway, if you earn money on my open source work, I will fucking end you :)