├── .github ├── FUNDING.yml └── workflows │ ├── publish.yml │ └── release.yml ├── index.js ├── examples ├── region.js ├── platform.js ├── serie.js ├── user.js ├── category.js ├── level.js ├── game.js └── run.js ├── lib ├── structures │ └── Endpoint.js ├── index.js ├── endpoints │ ├── region.js │ ├── platform.js │ ├── serie.js │ ├── user.js │ ├── category.js │ ├── level.js │ ├── game.js │ └── run.js └── Client.js ├── docs.js ├── package.json ├── .gitignore ├── README.md └── LICENSE /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: switchblade 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/Client.js') 2 | -------------------------------------------------------------------------------- /examples/region.js: -------------------------------------------------------------------------------- 1 | const SpeedrunClient = require('../lib/Client.js') 2 | const speedrun = new SpeedrunClient() 3 | 4 | // Get region details 5 | speedrun.regions.get('ypl25l47').then(console.log) 6 | -------------------------------------------------------------------------------- /examples/platform.js: -------------------------------------------------------------------------------- 1 | const SpeedrunClient = require('../lib/Client.js') 2 | const speedrun = new SpeedrunClient() 3 | 4 | // Get platform details 5 | speedrun.platforms.get('83exwk6l').then(console.log) 6 | -------------------------------------------------------------------------------- /lib/structures/Endpoint.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @ignore 3 | */ 4 | module.exports = class Endpoint { 5 | constructor (client) { 6 | this.client = client 7 | this.name = 'EndpointName' 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/serie.js: -------------------------------------------------------------------------------- 1 | const SpeedrunClient = require('../lib/Client.js') 2 | const speedrun = new SpeedrunClient() 3 | 4 | // Get serie details 5 | speedrun.series.get('8nwjpj7y').then(console.log) 6 | 7 | // Get serie games 8 | speedrun.series.getGames('8nwjpj7y').then(console.log) 9 | -------------------------------------------------------------------------------- /examples/user.js: -------------------------------------------------------------------------------- 1 | const SpeedrunClient = require('../lib/Client.js') 2 | const speedrun = new SpeedrunClient() 3 | 4 | // Get user details 5 | speedrun.users.get('pj00k3jw').then(console.log) 6 | 7 | // Get user personal bests 8 | speedrun.users.getPersonalBests('pj00k3jw').then(console.log) 9 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | Category: require('./endpoints/category'), 3 | Game: require('./endpoints/game'), 4 | Level: require('./endpoints/level'), 5 | Platform: require('./endpoints/platform'), 6 | Region: require('./endpoints/region'), 7 | Run: require('./endpoints/run'), 8 | Serie: require('./endpoints/serie'), 9 | User: require('./endpoints/user') 10 | } 11 | -------------------------------------------------------------------------------- /examples/category.js: -------------------------------------------------------------------------------- 1 | const SpeedrunClient = require('../lib/Client.js') 2 | const speedrun = new SpeedrunClient() 3 | 4 | // Get category details 5 | speedrun.categories.get('j1npme6p').then(console.log) 6 | 7 | // Get category variables 8 | speedrun.categories.getVariables('j1npme6p').then(console.log) 9 | 10 | // Get category records 11 | speedrun.categories.getRecords('j1npme6p').then(console.log) 12 | -------------------------------------------------------------------------------- /examples/level.js: -------------------------------------------------------------------------------- 1 | const SpeedrunClient = require('../lib/Client.js') 2 | const speedrun = new SpeedrunClient() 3 | 4 | // Get level details 5 | speedrun.levels.get('owo7e5v9').then(console.log) 6 | 7 | // Get level categories 8 | speedrun.levels.getCategories('owo7e5v9').then(console.log) 9 | 10 | // Get level variables 11 | speedrun.levels.getVariables('owo7e5v9').then(console.log) 12 | 13 | // Get level records 14 | speedrun.levels.getRecords('owo7e5v9').then(console.log) 15 | -------------------------------------------------------------------------------- /lib/endpoints/region.js: -------------------------------------------------------------------------------- 1 | const Endpoint = require('../structures/Endpoint.js') 2 | 3 | class Region extends Endpoint { 4 | constructor (client) { 5 | super(client) 6 | this.name = 'regions' 7 | } 8 | 9 | /** 10 | * Get region details 11 | * @param {String} regionId - Region ID you want to get details about 12 | * @returns {Promise} - Returned promise 13 | */ 14 | get (regionId) { 15 | return this.client.get(`/regions/${regionId}`) 16 | } 17 | } 18 | 19 | module.exports = Region 20 | -------------------------------------------------------------------------------- /lib/endpoints/platform.js: -------------------------------------------------------------------------------- 1 | const Endpoint = require('../structures/Endpoint.js') 2 | 3 | class Platform extends Endpoint { 4 | constructor (client) { 5 | super(client) 6 | this.name = 'platforms' 7 | } 8 | 9 | /** 10 | * Get platform details 11 | * @param {String} platformId - Platform ID you want to get details about 12 | * @returns {Promise} - Returned promise 13 | */ 14 | get (platformId) { 15 | return this.client.get(`/platforms/${platformId}`) 16 | } 17 | } 18 | 19 | module.exports = Platform 20 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [ created ] 6 | 7 | jobs: 8 | npm: 9 | name: Publish 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v1 13 | name: Checkout Code 14 | - uses: actions/setup-node@v1 15 | name: Setup Node 16 | with: 17 | node-version: 12 18 | registry-url: https://registry.npmjs.org/ 19 | - run: npm install 20 | name: Install dependencies 21 | - run: npm publish 22 | name: Publish 23 | env: 24 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} -------------------------------------------------------------------------------- /examples/game.js: -------------------------------------------------------------------------------- 1 | const SpeedrunClient = require('../lib/Client.js') 2 | const speedrun = new SpeedrunClient() 3 | 4 | // Get game details 5 | speedrun.games.get('j1npme6p').then(console.log) 6 | 7 | // Get game levels 8 | speedrun.games.getLevels('j1npme6p').then(console.log) 9 | 10 | // Get games by region 11 | speedrun.games.getByRegion('ypl25l47').then(console.log) 12 | 13 | // Get games by platform 14 | speedrun.games.getByPlatform('83exwk6l').then(console.log) 15 | 16 | // Get derived games 17 | speedrun.games.getDerivedGames('j1npme6p').then(console.log) 18 | 19 | // Get game leaderboard 20 | speedrun.games.getLeaderboard('v1pjk418', 'q25w6v2o').then(console.log) 21 | -------------------------------------------------------------------------------- /lib/endpoints/serie.js: -------------------------------------------------------------------------------- 1 | const Endpoint = require('../structures/Endpoint.js') 2 | 3 | class Serie extends Endpoint { 4 | constructor (client) { 5 | super(client) 6 | this.name = 'series' 7 | } 8 | 9 | /** 10 | * Get serie details 11 | * @param {String} serieId - Serie ID you want to get details about 12 | * @returns {Promise} - Returned promise 13 | */ 14 | get (serieId) { 15 | return this.client.get(`/series/${serieId}`) 16 | } 17 | 18 | /** 19 | * Get serie games 20 | * @param {String} serieId - Serie ID you want to get games from 21 | * @returns {Promise} - Returned promise 22 | */ 23 | getGames (serieId) { 24 | return this.client.get(`/series/${serieId}/games`) 25 | } 26 | } 27 | 28 | module.exports = Serie 29 | -------------------------------------------------------------------------------- /lib/endpoints/user.js: -------------------------------------------------------------------------------- 1 | const Endpoint = require('../structures/Endpoint.js') 2 | 3 | class User extends Endpoint { 4 | constructor (client) { 5 | super(client) 6 | this.name = 'users' 7 | } 8 | 9 | /** 10 | * Get user details 11 | * @param {String} user - User name or ID you want to get details about 12 | * @returns {Promise} - Returned promise 13 | */ 14 | get (user) { 15 | return this.client.get(`/users/${user}`) 16 | } 17 | 18 | /** 19 | * Get user's personal bests 20 | * @param {String} user - User name or ID you want to get personal bests from 21 | * @returns {Promise} - Returned promise 22 | */ 23 | getPersonalBests (user) { 24 | return this.client.get(`/users/${user}/personal-bests`) 25 | } 26 | } 27 | 28 | module.exports = User 29 | -------------------------------------------------------------------------------- /examples/run.js: -------------------------------------------------------------------------------- 1 | const SpeedrunClient = require('../lib/Client.js') 2 | const speedrun = new SpeedrunClient() 3 | 4 | // Get run details 5 | speedrun.runs.get('0y6p1e1m').then(console.log) 6 | 7 | // Get runs from a specific game 8 | speedrun.runs.getFromGame('j1npme6p').then(console.log) 9 | 10 | // Get runs from a specific user 11 | speedrun.runs.getFromUser('pj00k3jw').then(console.log) 12 | 13 | // Get runs from a specific region 14 | speedrun.runs.getFromRegion('ypl25l47').then(console.log) 15 | 16 | // Get runs from a specific level 17 | speedrun.runs.getFromLevel('5928n796').then(console.log) 18 | 19 | // Get runs from a specific platform 20 | speedrun.runs.getFromPlatform('83exwk6l').then(console.log) 21 | 22 | // Get runs from a specific category 23 | speedrun.runs.getFromCategory('q25w6v2o').then(console.log) 24 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | checkversion: 10 | name: Release if needed 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: MontyD/package-json-updated-action@1.0.1 14 | name: Version Changed? 15 | id: version-updated 16 | with: 17 | path: package.json 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | - if: steps.version-updated.outputs.has-updated 21 | name: Create Release 22 | id: create_release 23 | uses: actions/create-release@v1 24 | env: 25 | GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} 26 | with: 27 | tag_name: ${{ steps.version-updated.outputs.current-package-version }} 28 | release_name: ${{ steps.version-updated.outputs.current-package-version }} 29 | prerelease: ${{ startsWith(steps.version-updated.outputs.current-package-version, '0.') }} -------------------------------------------------------------------------------- /docs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Docma = require('docma') 4 | const Package = require('./package') 5 | 6 | Docma.create().build({ 7 | app: { 8 | title: `${Package.name}: Node.js wrapper for the Speedrun.com API`, 9 | base: '/', 10 | entrance: 'api:node-speedrun', 11 | routing: 'query', 12 | server: Docma.ServerType.STATIC 13 | }, 14 | markdown: { 15 | gfm: true, 16 | tables: true, 17 | breaks: false, 18 | pedantic: false, 19 | sanitize: false, 20 | smartLists: false, 21 | smartypants: false, 22 | tasks: false, 23 | emoji: true 24 | }, 25 | jsdoc: { 26 | module: false 27 | }, 28 | src: [ 29 | { 'node-speedrun': './lib/**/*.js' } 30 | ], 31 | dest: './docs', 32 | template: { 33 | options: { 34 | title: Package.name, 35 | navItems: [ 36 | { 37 | iconClass: 'fab fa-lg fa-github', 38 | label: 'GitHub', 39 | href: 'https://github.com/SwitchbladeBot/node-speedrun', 40 | target: '_blank' 41 | } 42 | ] 43 | } 44 | } 45 | }) 46 | -------------------------------------------------------------------------------- /lib/endpoints/category.js: -------------------------------------------------------------------------------- 1 | const Endpoint = require('../structures/Endpoint.js') 2 | 3 | class Category extends Endpoint { 4 | constructor (client) { 5 | super(client) 6 | this.name = 'categories' 7 | } 8 | 9 | /** 10 | * Get category details 11 | * @param {String} categoryId - Category ID you want to get details about 12 | * @returns {Promise} - Returned promise 13 | */ 14 | get (categoryId) { 15 | return this.client.get(`/categories/${categoryId}`) 16 | } 17 | 18 | /** 19 | * Get category variables 20 | * @param {String} categoryId - Category ID you want to get variables from 21 | * @returns {Promise} - Returned promise 22 | */ 23 | getVariables (categoryId) { 24 | return this.client.get(`/categories/${categoryId}/variables`) 25 | } 26 | 27 | /** 28 | * Get category records 29 | * @param {String} categoryId - Category ID you want to get records from 30 | * @returns {Promise} - Returned promise 31 | */ 32 | getRecords (categoryId) { 33 | return this.client.get(`/categories/${categoryId}/records`) 34 | } 35 | } 36 | 37 | module.exports = Category 38 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-speedrun", 3 | "version": "1.3.0", 4 | "description": "Node.js wrapper for the Speedrun.com API", 5 | "main": "index.js", 6 | "scripts": { 7 | "test-docs": "npm run build-docs && docma serve ./docs/", 8 | "build-docs": "node docs.js", 9 | "test": "standard", 10 | "standard-fix": "standard --fix" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/SwitchbladeBot/node-speedrun.git" 15 | }, 16 | "keywords": [ 17 | "speedrun", 18 | "speedruncom", 19 | "api", 20 | "wrapper" 21 | ], 22 | "author": "Switchblade Team ", 23 | "license": "BSD-3-Clause", 24 | "bugs": { 25 | "url": "https://github.com/SwitchbladeBot/node-speedrun/issues" 26 | }, 27 | "homepage": "https://speedrun.switchblade.xyz/", 28 | "devDependencies": { 29 | "docma": "^3.2.2", 30 | "dotenv": "^7.0.0", 31 | "eslint-config-standard": "^12.0.0", 32 | "eslint-plugin-import": "^2.22.0", 33 | "eslint-plugin-node": "^8.0.1", 34 | "eslint-plugin-promise": "^4.2.1", 35 | "eslint-plugin-standard": "^4.0.1", 36 | "standard": "^12.0.1" 37 | }, 38 | "dependencies": { 39 | "axios": "^0.27.2" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | # JetBrains stuff 64 | .idea/ 65 | 66 | # Docma build folder 67 | docs/ -------------------------------------------------------------------------------- /lib/endpoints/level.js: -------------------------------------------------------------------------------- 1 | const Endpoint = require('../structures/Endpoint.js') 2 | 3 | class Level extends Endpoint { 4 | constructor (client) { 5 | super(client) 6 | this.name = 'levels' 7 | } 8 | 9 | /** 10 | * Get level details 11 | * @param {String} levelId - Level ID you want to get details about 12 | * @returns {Promise} - Returned promise 13 | */ 14 | get (levelId) { 15 | return this.client.get(`/levels/${levelId}`) 16 | } 17 | 18 | /** 19 | * Get level categories 20 | * @param {String} levelId - Level ID you want to get categories from 21 | * @returns {Promise} - Returned promise 22 | */ 23 | getCategories (levelId) { 24 | return this.client.get(`/levels/${levelId}/categories`) 25 | } 26 | 27 | /** 28 | * Get level variables 29 | * @param {String} levelId - Level ID you want to get variables from 30 | * @returns {Promise} - Returned promise 31 | */ 32 | getVariables (levelId) { 33 | return this.client.get(`/levels/${levelId}/variables`) 34 | } 35 | 36 | /** 37 | * Get level records 38 | * @param {String} levelId - Level ID you want to get records from 39 | * @returns {Promise} - Returned promise 40 | */ 41 | getRecords (levelId) { 42 | return this.client.get(`/levels/${levelId}/records`) 43 | } 44 | } 45 | 46 | module.exports = Level 47 | -------------------------------------------------------------------------------- /lib/Client.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios') 2 | 3 | const { Category, Game, Level, Platform, Region, Run, Serie, User } = require('./index') 4 | 5 | class Client { 6 | /** 7 | * @param {Object} [options] - Options of Client 8 | * @param {String} [options.userAgent] - User Agent to be used for every request 9 | * @param {String} [options.baseUrl] - Base URL for the API 10 | */ 11 | constructor (options = {}) { 12 | this.userAgent = options.userAgent || 'node-speedrun (https://npmjs.com/package/node-speedrun)' 13 | this.baseUrl = options.baseUrl || 'https://www.speedrun.com/api/v1' 14 | 15 | this.categories = new Category(this) 16 | this.games = new Game(this) 17 | this.levels = new Level(this) 18 | this.platforms = new Platform(this) 19 | this.regions = new Region(this) 20 | this.runs = new Run(this) 21 | this.series = new Serie(this) 22 | this.users = new User(this) 23 | } 24 | 25 | /** 26 | * Performs a GET request to an endpoint on the API 27 | * @param {String} endpoint - Endpoint to perform the request to 28 | * @returns {Promise} - Returned promise 29 | */ 30 | get (endpoint) { 31 | return axios.get(`${this.baseUrl}${endpoint}`, { 32 | headers: { 'User-Agent': this.userAgent } 33 | }).then(res => res.data) 34 | } 35 | } 36 | 37 | module.exports = Client 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 | Node.js wrapper for the Speedrun.com API 4 |

5 |

6 | Documentation deployed by Netlify 7 |
8 | Discord Server 9 | License 10 | 11 | 12 |

13 | 14 | `npm install node-speedrun` 15 | 16 | Read the documentation 17 |
18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022, SwitchbladeBot 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. All advertising materials mentioning features or use of this software 12 | must display the following acknowledgement: 13 | This product includes software developed by the SwitchbladeBot. 14 | 4. Neither the name of the SwitchbladeBot nor the 15 | names of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY SWITCHBLADEBOT "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL SWITCHBLADEBOT BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /lib/endpoints/game.js: -------------------------------------------------------------------------------- 1 | const Endpoint = require('../structures/Endpoint.js') 2 | 3 | class Game extends Endpoint { 4 | constructor (client) { 5 | super(client) 6 | this.name = 'games' 7 | } 8 | 9 | /** 10 | * Get game details 11 | * @param {String} game - Game abbreviation or ID you want to get details about 12 | * @returns {Promise} - Returned promise 13 | */ 14 | get (game) { 15 | return this.client.get(`/games/${game}`) 16 | } 17 | 18 | /** 19 | * Get game levels 20 | * @param {String} gameId - Game ID you want to get levels from 21 | * @returns {Promise} - Returned promise 22 | */ 23 | getLevels (gameId) { 24 | return this.client.get(`/games/${gameId}/levels`) 25 | } 26 | 27 | /** 28 | * Gets games by region 29 | * @param {String} region - Region ID you want to get games from 30 | * @returns {Promise} - Returned promise 31 | */ 32 | getByRegion (region) { 33 | return this.client.get(`/games`, { qs: { region } }) 34 | } 35 | 36 | /** 37 | * Gets games by platform 38 | * @param {String} platform - Platform ID you want to get games from 39 | * @returns {Promise} - Returned promise 40 | */ 41 | getByPlatform (platform) { 42 | return this.client.get(`/games`, { qs: { platform } }) 43 | } 44 | 45 | /** 46 | * Get derived games 47 | * @param {String} game - Game abbreviation or ID you want to get derived games from 48 | * @returns {Promise} - Returned promise 49 | */ 50 | getDerivedGames (game) { 51 | return this.client.get(`/games/${game}/derived-games`) 52 | } 53 | 54 | /** 55 | * Get game leaderboard 56 | * @param {String} gameId - Game ID you want to get the leaderboard from 57 | * @param {String} categoryId - Category ID you want to get the leaderboard from 58 | * @returns {Promise} - Returned promise 59 | */ 60 | getLeaderboard (gameId, categoryId) { 61 | return this.client.get(`/leaderboards/${gameId}/category/${categoryId}`) 62 | } 63 | } 64 | 65 | module.exports = Game 66 | -------------------------------------------------------------------------------- /lib/endpoints/run.js: -------------------------------------------------------------------------------- 1 | const Endpoint = require('../structures/Endpoint.js') 2 | 3 | class Run extends Endpoint { 4 | constructor (client) { 5 | super(client) 6 | this.name = 'runs' 7 | } 8 | 9 | /** 10 | * Get run details 11 | * @param {String} runId - Run ID you want to get details about 12 | * @returns {Promise} - Returned promise 13 | */ 14 | get (runId) { 15 | return this.client.get(`/runs/${runId}`) 16 | } 17 | 18 | /** 19 | * Get runs from a specific game 20 | * @param {String} gameId - Game ID you want to get runs from 21 | * @returns {Promise} - Returned promise 22 | */ 23 | getFromGame (gameId) { 24 | return this.client.get(`/runs`, { qs: { game: gameId } }) 25 | } 26 | 27 | /** 28 | * Get runs from a specific user 29 | * @param {String} userId - User ID you want to get runs from 30 | * @returns {Promise} - Returned promise 31 | */ 32 | getFromUser (userId) { 33 | return this.client.get(`/runs`, { qs: { user: userId } }) 34 | } 35 | 36 | /** 37 | * Get runs from a specific region 38 | * @param {String} regionId - Region ID you want to get runs from 39 | * @returns {Promise} - Returned promise 40 | */ 41 | getFromRegion (regionId) { 42 | return this.client.get(`/runs`, { qs: { region: regionId } }) 43 | } 44 | 45 | /** 46 | * Get runs from a specific level 47 | * @param {String} levelId - Level ID you want to get runs from 48 | * @returns {Promise} - Returned promise 49 | */ 50 | getFromLevel (levelId) { 51 | return this.client.get(`/runs`, { qs: { level: levelId } }) 52 | } 53 | 54 | /** 55 | * Get runs from a specific platform 56 | * @param {String} platformId - Platform ID you want to get runs from 57 | * @returns {Promise} - Returned promise 58 | */ 59 | getFromPlatform (platformId) { 60 | return this.client.get(`/runs`, { qs: { platform: platformId } }) 61 | } 62 | 63 | /** 64 | * Get runs from a specific category 65 | * @param {String} categoryId - Category ID you want to get runs from 66 | * @returns {Promise} - Returned promise 67 | */ 68 | getFromCategory (categoryId) { 69 | return this.client.get(`/runs`, { qs: { category: categoryId } }) 70 | } 71 | } 72 | 73 | module.exports = Run 74 | --------------------------------------------------------------------------------