From ff5dfe4d372cc02426508ee4debf8ec3f84dc393 Mon Sep 17 00:00:00 2001 From: SpatzlHD Date: Sun, 24 Apr 2022 21:26:49 +0200 Subject: [PATCH 1/6] Added Valorant-API.com Wrapper --- index.js | 14 +- src/assatesApi.js | 510 ++++++++++++++++++++++++++++++++++++++++++++++ src/languages.js | 22 ++ 3 files changed, 540 insertions(+), 6 deletions(-) create mode 100644 src/assatesApi.js create mode 100644 src/languages.js diff --git a/index.js b/index.js index 5081952..58d0ec7 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,9 @@ module.exports = { - API: require("./src/api"), - Maps: require("./src/maps"), - Regions: require("./src/regions"), - Tiers: require("./src/tiers"), - LocalRiotClientAPI: require("./src/LocalRiotClientAPI"), -}; \ No newline at end of file + API: require("./src/api"), + Maps: require("./src/maps"), + Regions: require("./src/regions"), + Tiers: require("./src/tiers"), + LocalRiotClientAPI: require("./src/LocalRiotClientAPI"), + assetsAPI: require("./src/assatesApi"), + languages: require("./src/languages"), +}; diff --git a/src/assatesApi.js b/src/assatesApi.js new file mode 100644 index 0000000..6cb74df --- /dev/null +++ b/src/assatesApi.js @@ -0,0 +1,510 @@ +"use strict"; + +const axios = require("axios").default; +const languages = require("./languages"); + +class assetsAPI { + /** + * Initialize the Assets API using https://valorant-api.com/ + * @param {string} language The language of the output + */ + constructor(language = languages.English) { + this.language = language; + this.baseURL = "https://valorant-api.com/v1/"; + } + //agent Endpoints + /** + * Get a list of all Agents + * @returns {Promise>} A list of all Agents + */ + getAgents() { + return axios.get(`${this.baseURL}agents`, { + params: { language: this.language, isPlayableCharacter: true }, + }); + } + /** + * Get a specific Agent by UUID + * @param {sting} uuid The UUID of the Agent + * @returns {Promise} Agent Object + */ + getAgentbyUuid(uuid) { + return axios.get(`${this.baseURL}agents/${uuid}`, { + params: { language: this.language }, + }); + } + //Buddies Endpoints + /** + * Get a list of all Buddies + * @returns {Promise>} A list of all Buddies + */ + getBuddies() { + return axios.get(`${this.baseURL}buddies`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of all weapon buddy levels + * @returns {Promise>} A list of all Buddy Levels + */ + getBuddyLevels() { + return axios.get(`${this.baseURL}buddies/levels`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested weapon buddy + * @param {string} uuid The UUID of the Buddy + * @returns {Promise} Buddy Object + */ + getBuddybyUuid(uuid) { + return axios.get(`${this.baseURL}buddies/${uuid}`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested weapon buddy level + * @param {sting} uuid Buddy UUID + * @returns {Promise} BuddyLevel Object + */ + getBuddyLevelbyUuid(uuid) { + return axios.get(`${this.baseURL}buddies/levels/${uuid}`, { + params: { language: this.language }, + }); + } + //Bundle Endpoints + /** + * Returns a list of all Bundles + * @returns {Promise>} A list of all Bundles + */ + getBundles() { + return axios.get(`${this.baseURL}bundles`, { + params: { language: this.language }, + }); + } + /** + *Returns data and assets of the requested bundle + * @param {sting} uuid Bundle UUID + * @returns {Promise} Bundle Object + */ + getBundlebyUuid(uuid) { + return axios.get(`${this.baseURL}bundles/${uuid}`, { + params: { language: this.language }, + }); + } + //ceremony Endpoints + /** + * Returns data and assets of all ceremonies + * @returns {Promise>} A list of all Ceremonies + */ + getCeremonies() { + return axios.get(`${this.baseURL}ceremonies`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested ceremony + * @param {string} uuid Ceremony UUID + * @returns {Promise} Ceremony Object + */ + getCeremonybyUuid(uuid) { + return axios.get(`${this.baseURL}ceremonies/${uuid}`, { + params: { language: this.language }, + }); + } + //Competitive Tiers Endpoints + /** + * Returns data and assets of all competitive tiers + * @returns {Promise>} A list of all Competitive Tiers + */ + getCompetitiveTiers() { + return axios.get(`${this.baseURL}competitivetiers`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets the requested competitive tier table + * @param {string} uuid Competitive Tier UUID + * @returns {Promise} CompetitiveTier Object + */ + getCompetitiveTierbyUuid(uuid) { + return axios.get(`${this.baseURL}competitivetiers/${uuid}`, { + params: { language: this.language }, + }); + } + //Content Tiers Endpoints + /** + * Returns data and assets of all content tiers + * @returns {Promise>} A list of all Content Tiers + */ + getContentTiers() { + return axios.get(`${this.baseURL}contenttiers`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets for the requested content tier + * @param {string} uuid Content Tier UUID + * @returns {Promise} ContentTier Object + */ + getContentTierbyUuid(uuid) { + return axios.get(`${this.baseURL}contenttiers/${uuid}`, { + params: { language: this.language }, + }); + } + //Contract Endpoints + /** + * Returns data and assets of all contracts + * @returns {Promise>} A list of all Contracts + */ + getContracts() { + return axios.get(`${this.baseURL}contracts`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets the requested contract + * @param {string} uuid Contract UUID + * @returns {Promise} Contract Object + */ + getContractbyUuid(uuid) { + return axios.get(`${this.baseURL}contracts/${uuid}`, { + params: { language: this.language }, + }); + } + //Currencies Endpoints + /** + * Returns data and assets of all in-game currencies + * @returns {Promise>} A list of all Currencies + */ + getCurrencies() { + return axios.get(`${this.baseURL}currencies`, { + params: { language: this.language }, + }); + } + /** + *Returns data and assets the requested in-game currency + * @param {string} uuid Currency UUID + * @returns {Promise} Currency Object + */ + getCurrencybyUuid(uuid) { + return axios.get(`${this.baseURL}currencies/${uuid}`, { + params: { language: this.language }, + }); + } + //Events Endpoints + /** + * Returns data and assets of all events + * @returns {Promise>} A list of all Events + */ + getEvents() { + return axios.get(`${this.baseURL}events`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets the requested event + * @param {string} uuid Event UUID + * @returns {Promise} Event Object + */ + getEventbyUuid(uuid) { + return axios.get(`${this.baseURL}events/${uuid}`, { + params: { language: this.language }, + }); + } + //Gamemode Endpoints + /** + * Returns data and assets of all gamemodes + * @returns {Promise>} A list of all Gamemodes + */ + getGameModes() { + return axios.get(`${this.baseURL}gamemodes`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of all gamemode equippables + * @returns {Promise>} A list of all Gamemode Equippables + */ + getGamemodeEquippables() { + return axios.get(`${this.baseURL}gamemodes/equippables`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested gamemode + * @param {string} uuid + * @returns {Promise} Gamemode Object + */ + getGameModebyUuid(uuid) { + return axios.get(`${this.baseURL}gamemodes/${uuid}`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested gamemode equippable + * @param {string} uuid Gamemode Equippable UUID + * @returns {Promise} Gamemode Equippable Object + */ + getGamemodeEquippablebyUuid(uuid) { + return axios.get(`${this.baseURL}gamemodes/equippables/${uuid}`, { + params: { language: this.language }, + }); + } + //Gear Endpoints + /** + * Returns data and assets of all gear + * @returns {Promise>} A list of all Gear + */ + getGear() { + return axios.get(`${this.baseURL}gear`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested gear + * @param {string} uuid Gear UUID + * @returns {Promise} Gear Object + */ + getGearbyUuid(uuid) { + return axios.get(`${this.baseURL}gear/${uuid}`, { + params: { language: this.language }, + }); + } + //Map Endpoints + /** + * Returns data and assets of all maps + * @returns {Promise>} A list of all Maps + */ + getMaps() { + return axios.get(`${this.baseURL}maps`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested map + * @param {string} uuid Map UUID + * @returns {Promise} Map Object + */ + getMapbyUuid(uuid) { + return axios.get(`${this.baseURL}maps/${uuid}`, { + params: { language: this.language }, + }); + } + //Player Cards Endpoints + /** + * Returns data and assets of all player cards + * @returns {Promise>} A list of all Player Cards + */ + getPlayerCards() { + return axios.get(`${this.baseURL}playercards`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested player card + * @param {string} uuid Player Card UUID + * @returns {Promise} Player Card Object + */ + getPlayerCardbyUuid(uuid) { + return axios.get(`${this.baseURL}playercards/${uuid}`, { + params: { language: this.language }, + }); + } + //Player Titles Endpoints + /** + * Returns data and assets of all player titles + * @returns {Promise>} A list of all Player Titles + */ + getPlayerTitles() { + return axios.get(`${this.baseURL}playertitles`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested player title + * @param {string} uuid Player Title UUID + * @returns {Promise} Player Title Object + */ + getPlayerTitlebyUuid(uuid) { + return axios.get(`${this.baseURL}playertitles/${uuid}`, { + params: { language: this.language }, + }); + } + //Seasons Endpoints + /** + * Returns data and assets of all seasons + * @returns {Promise>} A list of all Seasons + */ + getSeasons() { + return axios.get(`${this.baseURL}seasons`, { + params: { language: this.language }, + }); + } + /** + * Returns data of all competitive seasons + * @returns {Promise>} A list of all Competitive Seasons + */ + getCompetitiveSeasons() { + return axios.get(`${this.baseURL}seasons/competitive`, { + params: { language: this.language }, + }); + } + /** + * Returns data of the requested season + * @param {string} uuid Season UUID + * @returns {Promise} Season Object + */ + getSeasonbyUuid(uuid) { + return axios.get(`${this.baseURL}seasons/${uuid}`, { + params: { language: this.language }, + }); + } + /** + * Returns data of the requested competitive season + * @param {string} uuid Competitive Season UUID + * @returns {Promise} Competitive Season Object + */ + getCompetitiveSeasonbyUuid(uuid) { + return axios.get(`${this.baseURL}seasons/competitive/${uuid}`, { + params: { language: this.language }, + }); + } + //Spray Endpoints + /** + * Returns data and assets of all sprays + * @returns {Promise>} A list of all Seasons + */ + getSprays() { + return axios.get(`${this.baseURL}sprays`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of all spray levels + * @returns {Promise>} A list of all Sprays + */ + getSprayLevels() { + return axios.get(`${this.baseURL}sprays/levels`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested spray + * @param {string} uuid Spray UUID + * @returns {Promise} Spray Object + */ + getSpraybyUuid(uuid) { + return axios.get(`${this.baseURL}sprays/${uuid}`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested spray level + * @param {string} uuid Spray Level UUID + * @returns {Promise} Spray Level Object + */ + getSprayLevelbyUuid(uuid) { + return axios.get(`${this.baseURL}sprays/levels/${uuid}`, { + params: { language: this.language }, + }); + } + //Theme Endpoints + /** + * Returns data and assets of all themes + * @returns {Promise>} A list of all Themes + */ + getThemes() { + return axios.get(`${this.baseURL}themes`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested theme + * @param {string} uuid Theme UUID + * @returns {Promise} Theme Object + */ + getThemebyUuid(uuid) { + return axios.get(`${this.baseURL}themes/${uuid}`, { + params: { language: this.language }, + }); + } + //Weapon Endpoints + /** + * Returns data and assets of all weapons + * @returns {Promise>} A list of all Weapons + */ + getWeapons() { + return axios.get(`${this.baseURL}weapons`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of all weapon skins + * @returns {Promise>} A list of all Weapons + */ + getWeaponsSkins() { + return axios.get(`${this.baseURL}weapons/skins`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of all weapon skin chromas + * @returns {Promise>} A list of all Weapon Skins Chromas + */ + getWeaponSkinChromas() { + return axios.get(`${this.baseURL}weapons/skinchromas`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of all weapon skin levels + * @returns {Promise>} A list of all Weapon Skin Levels + */ + getWeaponSkinLevels() { + return axios.get(`${this.baseURL}weapons/skinlevels`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requeted weapon + * @param {string} uuid Weapon UUID + * @returns {Promise} Weapon Object + */ + getWeaponbyUuid(uuid) { + return axios.get(`${this.baseURL}weapons/${uuid}`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requested weapon skin + * @param {string} uuid Weapon Skin UUID + * @returns {Promise} Weapon Skin Object + */ + getWeaponSkinbyUuid(uuid) { + return axios.get(`${this.baseURL}weapons/skins/${uuid}`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requeted weapon skin chroma + * @param {string} uuid Weapon Skin Chroma UUID + * @returns {Promise} Weapon Skin Chroma Object + */ + getWeaponSkinChromaByUuid(uuid) { + return axios.get(`${this.baseURL}weapons/skinchromas/${uuid}`, { + params: { language: this.language }, + }); + } + /** + * Returns data and assets of the requeted weapon skin level + * @param {string} uuid Weapon Skin Level UUID + * @returns {Promise} Weapon Skin Level Object + */ + getWeaponSkinLevelByUuid(uuid) { + return axios.get(`${this.baseURL}weapons/skinlevels/${uuid}`, { + params: { language: this.language }, + }); + } +} + +module.exports = assetsAPI; diff --git a/src/languages.js b/src/languages.js new file mode 100644 index 0000000..809c467 --- /dev/null +++ b/src/languages.js @@ -0,0 +1,22 @@ +const languages = { + Arabic: "ar-AE", + German: "de-DE", + English: "en-US", + Spanish_Spain: "es-ES", + Spanish_Mexico: "es-MX", + French: "fr-FR", + Indonesian: "id-ID", + Italien: "it-IT", + Japanese: "ja-JP", + Korean: "ko-KR", + Polish: "pl-PL", + Portuguese_Brazil: "pt-BR", + Russian: "ru-RU", + Thai: "th-TH", + Turkish: "tr-TR", + Vietnamese: "vi-VN", + Chinese_Simplified: "zh-CN", + Chinese_Traditional: "zh-TW", +}; + +module.exports = languages; From 5fc48ed7f507d959ab19f96a8b3f2f8a87c3c71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6gel?= <79466158+SpatzlHD@users.noreply.github.com> Date: Mon, 25 Apr 2022 10:38:41 +0000 Subject: [PATCH 2/6] Renamed AssetApi to Content API and started working on the Content API Docs --- docs/ContentApi.md | 3 +++ index.js | 2 +- src/{assatesApi.js => contentApi.js} | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 docs/ContentApi.md rename src/{assatesApi.js => contentApi.js} (99%) diff --git a/docs/ContentApi.md b/docs/ContentApi.md new file mode 100644 index 0000000..f10e9b1 --- /dev/null +++ b/docs/ContentApi.md @@ -0,0 +1,3 @@ +# Content API + +*To provide the Data we are using the [valorant-api.com](https://valorant-api.com)* \ No newline at end of file diff --git a/index.js b/index.js index 58d0ec7..0e1b65c 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,6 @@ module.exports = { Regions: require("./src/regions"), Tiers: require("./src/tiers"), LocalRiotClientAPI: require("./src/LocalRiotClientAPI"), - assetsAPI: require("./src/assatesApi"), + Content: require("./src/contentApi"), languages: require("./src/languages"), }; diff --git a/src/assatesApi.js b/src/contentApi.js similarity index 99% rename from src/assatesApi.js rename to src/contentApi.js index 6cb74df..8ac8bb3 100644 --- a/src/assatesApi.js +++ b/src/contentApi.js @@ -3,7 +3,7 @@ const axios = require("axios").default; const languages = require("./languages"); -class assetsAPI { +class Content { /** * Initialize the Assets API using https://valorant-api.com/ * @param {string} language The language of the output From fef126199e0d4ba22b6918906704544afce7e440 Mon Sep 17 00:00:00 2001 From: SpatzlHD Date: Mon, 25 Apr 2022 19:57:23 +0200 Subject: [PATCH 3/6] Finished the Documantation and the Content API --- docs/ContentApi.md | 149 +++++++++++++++++++++++++- index.js | 2 +- src/contentApi.js | 258 +++++++++++++++++++++++++++------------------ 3 files changed, 304 insertions(+), 105 deletions(-) diff --git a/docs/ContentApi.md b/docs/ContentApi.md index f10e9b1..107e0e2 100644 --- a/docs/ContentApi.md +++ b/docs/ContentApi.md @@ -1,3 +1,150 @@ # Content API -*To provide the Data we are using the [valorant-api.com](https://valorant-api.com)* \ No newline at end of file +_This is an API wrapper for the_ [_valorant-api.com_](https://valorant-api.com) _API_ + +#### Getting Started: + +First you need to import the Content module and the Language Module. This is how it works: + +```javascript +const { Content, Languages } = require("@liamcottle/valorant.js"); +``` + +Next, you need to create an Content instance. Here you have the possibility to choose the Language in which the data will be delivered. By deafult the language is set to English. Here is a list of all available languages: + +| **Languages** | +| :-----------------: | +| German | +| English | +| Spanish_Spain | +| Spanish_Mexico | +| French | +| Indonesian | +| Italien | +| Japanese | +| Korean | +| Polish | +| Portuguese_Brazil | +| Russian | +| Thai | +| Turkish | +| Vietnamese | +| Chinese_Simplified | +| Chinese_Traditional | + +```js +const content = new ContentAPI(languages.English); +``` + +After you have created the ContentAPI instance you can start fetching data. For this you can either use _async/await_ or _.then_ this works as follows: +**Async/Await:** + +```js +//Send a request to get all agents +const data = await content.getAgents(); +//Log the received data in the console +console.log(data); +``` + +**.then** + +```js +content.getAgents().then((data) => { + //log data + console.log(data); +}); +``` + +Here is a example on how to get the Daily Store of a Player and then get the Asset Data using the ContentAPI and the [ClientAPI](https://github.com/liamcottle/valorant.js#readme) this Package provides. + +```js +//import modules +const { API, Content, languages, Regions } = require("@liamcottle/valorant.js"); + +//initiate the API and the Content Module +const client = new API(Regions.EU); +const content = new Content(languages.English); + +//authorize using the ClientAPI +client.authorize("username", "password").then(() => { + client.getPlayerStoreFront(client.user_id).then(async (response) => { + //get assets for the first Skin in the Store + const item1 = await content.getWeaponSkinLevelbyUuid( + response.data.SkinsPanelLayout.SingleItemOffers[0] + ); + }); + //log item + console.log(item1); +}); +``` + +Here is a list of all available Endpoints for the ContentAPI: + +- **[Agents](https://dash.valorant-api.com/endpoints/agents)** + - getAgents() + - getAgentsbyUuid(_uuid_) +- **[Buddies](https://dash.valorant-api.com/endpoints/buddies)** + - getBuddies() + - getBuddyLevels() + - getBuddybyUuid(_uuid_) + - getBuddyLevelbyUuid(_uuid_) +- **[Bundles](https://dash.valorant-api.com/endpoints/bundles)** + - getBundles() + - getBundlebyUuid(_uuid_) +- **[Ceremonies](https://dash.valorant-api.com/endpoints/ceremonies)** + - getCeremonies() + - getCeremonybyUuid(_uuid_) +- **[Competitive Tiers](https://dash.valorant-api.com/endpoints/competitivetiers)** + - getCompetitiveTiers() + - getCompetitiveTierbyUuid(_uuid_) +- **[Content Tiers](https://dash.valorant-api.com/endpoints/contenttiers)** + - getContentTiers() + - getContentTierbyUuid(_uuid_) +- **[Contracts](https://dash.valorant-api.com/endpoints/contracts)** + - getContracts() + - getContractbyUuid(_uuid_) +- **[Currencies](https://dash.valorant-api.com/endpoints/currencies)** + - getCurrencies() + - getCurrencybyUuid(_uuid_) +- **[Events](https://dash.valorant-api.com/endpoints/events)** + - getEvents() + - getEventbyUuid(_uuid_) +- **[Gamemodes](https://dash.valorant-api.com/endpoints/gamemodes)** + - getGamemodes() + - getGamemodeEquippables() + - getGamemodebyUuid(_uuid_) + - getGamemodeEquippablebyUuid(_uuid_) +- **[Gear](https://dash.valorant-api.com/endpoints/gear)** + - getGear() + - getGearbyUuid(_uuid_) +- **[Maps](https://dash.valorant-api.com/endpoints/maps)** + - getMaps() + - getMapbyUuid(_uuid_) +- **[Player Cards](https://dash.valorant-api.com/endpoints/playercards)** + - getPlayerCards() + - getPlayerCardbyUuid(_uuid_) +- **[Player Titles](https://dash.valorant-api.com/endpoints/playertitles)** + - getPlayerTitles() + - getPlayerTitlebyUuid(_uuid_) +- **[Seasons](https://dash.valorant-api.com/endpoints/seasons)** + - getSeasons() + - getCompetitiveSeasons() + - getSeasonbyUuid(_uuid_) + - getCompetitiveSeasonbyUuid(_uuid_) +- **[Sprays](https://dash.valorant-api.com/endpoints/sprays)** + - getSprays() + - getSpraybyUuid(_uuid_) +- **[Themes](https://dash.valorant-api.com/endpoints/themes)** + - getThemes() + - getThemebyUuid(_uuid_) +- **[Weapons](https://dash.valorant-api.com/endpoints/weapons)** + - getWeapons() + - getWeaponSkins() + - getWeaponSkinChromas() + - get WeaponSkinLevels() + - getWeaponbyUuid(_uuid_) + - getWeaponSkinbyUuid(_uuid_) + - getWeaponSkinChromabyUuid(_uuid_) + - getWeaponSkinLevelbyUuid(_uuid_) + +_If you have any Issue or Suggestion please open an Issue on the [Github Repository](https://github.com/liamcottle/valorant.js) or join the [Discord Server](https://discord.gg/HUFEkChRpP)_ diff --git a/index.js b/index.js index 0e1b65c..3b9c2e9 100644 --- a/index.js +++ b/index.js @@ -5,5 +5,5 @@ module.exports = { Tiers: require("./src/tiers"), LocalRiotClientAPI: require("./src/LocalRiotClientAPI"), Content: require("./src/contentApi"), - languages: require("./src/languages"), + Languages: require("./src/languages"), }; diff --git a/src/contentApi.js b/src/contentApi.js index 8ac8bb3..fe75d9e 100644 --- a/src/contentApi.js +++ b/src/contentApi.js @@ -17,57 +17,62 @@ class Content { * Get a list of all Agents * @returns {Promise>} A list of all Agents */ - getAgents() { - return axios.get(`${this.baseURL}agents`, { + async getAgents() { + const data = await axios.get(`${this.baseURL}agents`, { params: { language: this.language, isPlayableCharacter: true }, }); + return data.data.data; } /** * Get a specific Agent by UUID * @param {sting} uuid The UUID of the Agent * @returns {Promise} Agent Object */ - getAgentbyUuid(uuid) { - return axios.get(`${this.baseURL}agents/${uuid}`, { + async getAgentbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}agents/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Buddies Endpoints /** * Get a list of all Buddies * @returns {Promise>} A list of all Buddies */ - getBuddies() { - return axios.get(`${this.baseURL}buddies`, { + async getBuddies() { + const data = await axios.get(`${this.baseURL}buddies`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of all weapon buddy levels * @returns {Promise>} A list of all Buddy Levels */ - getBuddyLevels() { - return axios.get(`${this.baseURL}buddies/levels`, { + async getBuddyLevels() { + const data = await axios.get(`${this.baseURL}buddies/levels`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested weapon buddy * @param {string} uuid The UUID of the Buddy * @returns {Promise} Buddy Object */ - getBuddybyUuid(uuid) { - return axios.get(`${this.baseURL}buddies/${uuid}`, { + async getBuddybyUuid(uuid) { + const data = await axios.get(`${this.baseURL}buddies/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested weapon buddy level * @param {sting} uuid Buddy UUID * @returns {Promise} BuddyLevel Object */ - getBuddyLevelbyUuid(uuid) { - return axios.get(`${this.baseURL}buddies/levels/${uuid}`, { + async getBuddyLevelbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}buddies/levels/${uuid}`, { params: { language: this.language }, }); } @@ -76,435 +81,482 @@ class Content { * Returns a list of all Bundles * @returns {Promise>} A list of all Bundles */ - getBundles() { - return axios.get(`${this.baseURL}bundles`, { + async getBundles() { + const data = await axios.get(`${this.baseURL}bundles`, { params: { language: this.language }, }); + return data.data.data; } /** *Returns data and assets of the requested bundle * @param {sting} uuid Bundle UUID * @returns {Promise} Bundle Object */ - getBundlebyUuid(uuid) { - return axios.get(`${this.baseURL}bundles/${uuid}`, { + async getBundlebyUuid(uuid) { + const data = await axios.get(`${this.baseURL}bundles/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //ceremony Endpoints /** * Returns data and assets of all ceremonies * @returns {Promise>} A list of all Ceremonies */ - getCeremonies() { - return axios.get(`${this.baseURL}ceremonies`, { + async getCeremonies() { + const data = await axios.get(`${this.baseURL}ceremonies`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested ceremony * @param {string} uuid Ceremony UUID * @returns {Promise} Ceremony Object */ - getCeremonybyUuid(uuid) { - return axios.get(`${this.baseURL}ceremonies/${uuid}`, { + async getCeremonybyUuid(uuid) { + const data = await axios.get(`${this.baseURL}ceremonies/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Competitive Tiers Endpoints /** * Returns data and assets of all competitive tiers * @returns {Promise>} A list of all Competitive Tiers */ - getCompetitiveTiers() { - return axios.get(`${this.baseURL}competitivetiers`, { + async getCompetitiveTiers() { + const data = await axios.get(`${this.baseURL}competitivetiers`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets the requested competitive tier table * @param {string} uuid Competitive Tier UUID * @returns {Promise} CompetitiveTier Object */ - getCompetitiveTierbyUuid(uuid) { - return axios.get(`${this.baseURL}competitivetiers/${uuid}`, { + async getCompetitiveTierbyUuid(uuid) { + const data = axios.get(`${this.baseURL}competitivetiers/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Content Tiers Endpoints /** * Returns data and assets of all content tiers * @returns {Promise>} A list of all Content Tiers */ - getContentTiers() { - return axios.get(`${this.baseURL}contenttiers`, { + async getContentTiers() { + const data = await axios.get(`${this.baseURL}contenttiers`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets for the requested content tier * @param {string} uuid Content Tier UUID * @returns {Promise} ContentTier Object */ - getContentTierbyUuid(uuid) { - return axios.get(`${this.baseURL}contenttiers/${uuid}`, { + async getContentTierbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}contenttiers/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Contract Endpoints /** * Returns data and assets of all contracts * @returns {Promise>} A list of all Contracts */ - getContracts() { - return axios.get(`${this.baseURL}contracts`, { + async getContracts() { + const data = await axios.get(`${this.baseURL}contracts`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets the requested contract * @param {string} uuid Contract UUID * @returns {Promise} Contract Object */ - getContractbyUuid(uuid) { - return axios.get(`${this.baseURL}contracts/${uuid}`, { + async getContractbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}contracts/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Currencies Endpoints /** * Returns data and assets of all in-game currencies * @returns {Promise>} A list of all Currencies */ - getCurrencies() { - return axios.get(`${this.baseURL}currencies`, { + async getCurrencies() { + const data = await axios.get(`${this.baseURL}currencies`, { params: { language: this.language }, }); + return data.data.data; } /** *Returns data and assets the requested in-game currency * @param {string} uuid Currency UUID * @returns {Promise} Currency Object */ - getCurrencybyUuid(uuid) { - return axios.get(`${this.baseURL}currencies/${uuid}`, { + async getCurrencybyUuid(uuid) { + const data = await axios.get(`${this.baseURL}currencies/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Events Endpoints /** * Returns data and assets of all events * @returns {Promise>} A list of all Events */ - getEvents() { - return axios.get(`${this.baseURL}events`, { + async getEvents() { + const data = await axios.get(`${this.baseURL}events`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets the requested event * @param {string} uuid Event UUID * @returns {Promise} Event Object */ - getEventbyUuid(uuid) { - return axios.get(`${this.baseURL}events/${uuid}`, { + async getEventbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}events/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Gamemode Endpoints /** * Returns data and assets of all gamemodes * @returns {Promise>} A list of all Gamemodes */ - getGameModes() { - return axios.get(`${this.baseURL}gamemodes`, { + async getGameModes() { + const data = await axios.get(`${this.baseURL}gamemodes`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of all gamemode equippables * @returns {Promise>} A list of all Gamemode Equippables */ - getGamemodeEquippables() { - return axios.get(`${this.baseURL}gamemodes/equippables`, { + async getGamemodeEquippables() { + const data = await axios.get(`${this.baseURL}gamemodes/equippables`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested gamemode * @param {string} uuid * @returns {Promise} Gamemode Object */ - getGameModebyUuid(uuid) { - return axios.get(`${this.baseURL}gamemodes/${uuid}`, { + async getGameModebyUuid(uuid) { + const data = await axios.get(`${this.baseURL}gamemodes/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested gamemode equippable * @param {string} uuid Gamemode Equippable UUID * @returns {Promise} Gamemode Equippable Object */ - getGamemodeEquippablebyUuid(uuid) { - return axios.get(`${this.baseURL}gamemodes/equippables/${uuid}`, { - params: { language: this.language }, - }); + async getGamemodeEquippablebyUuid(uuid) { + const data = await axios.get( + `${this.baseURL}gamemodes/equippables/${uuid}`, + { + params: { language: this.language }, + } + ); + return data.data.data; } //Gear Endpoints /** * Returns data and assets of all gear * @returns {Promise>} A list of all Gear */ - getGear() { - return axios.get(`${this.baseURL}gear`, { + async getGear() { + const data = await axios.get(`${this.baseURL}gear`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested gear * @param {string} uuid Gear UUID * @returns {Promise} Gear Object */ - getGearbyUuid(uuid) { - return axios.get(`${this.baseURL}gear/${uuid}`, { + async getGearbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}gear/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Map Endpoints /** * Returns data and assets of all maps * @returns {Promise>} A list of all Maps */ - getMaps() { - return axios.get(`${this.baseURL}maps`, { + async getMaps() { + const data = await axios.get(`${this.baseURL}maps`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested map * @param {string} uuid Map UUID * @returns {Promise} Map Object */ - getMapbyUuid(uuid) { - return axios.get(`${this.baseURL}maps/${uuid}`, { + async getMapbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}maps/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Player Cards Endpoints /** * Returns data and assets of all player cards * @returns {Promise>} A list of all Player Cards */ - getPlayerCards() { - return axios.get(`${this.baseURL}playercards`, { + async getPlayerCards() { + const data = await axios.get(`${this.baseURL}playercards`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested player card * @param {string} uuid Player Card UUID * @returns {Promise} Player Card Object */ - getPlayerCardbyUuid(uuid) { - return axios.get(`${this.baseURL}playercards/${uuid}`, { + async getPlayerCardbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}playercards/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Player Titles Endpoints /** * Returns data and assets of all player titles * @returns {Promise>} A list of all Player Titles */ - getPlayerTitles() { - return axios.get(`${this.baseURL}playertitles`, { + async getPlayerTitles() { + const data = await axios.get(`${this.baseURL}playertitles`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested player title * @param {string} uuid Player Title UUID * @returns {Promise} Player Title Object */ - getPlayerTitlebyUuid(uuid) { - return axios.get(`${this.baseURL}playertitles/${uuid}`, { + async getPlayerTitlebyUuid(uuid) { + const data = await axios.get(`${this.baseURL}playertitles/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Seasons Endpoints /** * Returns data and assets of all seasons * @returns {Promise>} A list of all Seasons */ - getSeasons() { - return axios.get(`${this.baseURL}seasons`, { + async getSeasons() { + const data = await axios.get(`${this.baseURL}seasons`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data of all competitive seasons * @returns {Promise>} A list of all Competitive Seasons */ - getCompetitiveSeasons() { - return axios.get(`${this.baseURL}seasons/competitive`, { + async getCompetitiveSeasons() { + const data = await axios.get(`${this.baseURL}seasons/competitive`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data of the requested season * @param {string} uuid Season UUID * @returns {Promise} Season Object */ - getSeasonbyUuid(uuid) { - return axios.get(`${this.baseURL}seasons/${uuid}`, { + async getSeasonbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}seasons/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data of the requested competitive season * @param {string} uuid Competitive Season UUID * @returns {Promise} Competitive Season Object */ - getCompetitiveSeasonbyUuid(uuid) { - return axios.get(`${this.baseURL}seasons/competitive/${uuid}`, { + async getCompetitiveSeasonbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}seasons/competitive/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Spray Endpoints /** * Returns data and assets of all sprays * @returns {Promise>} A list of all Seasons */ - getSprays() { - return axios.get(`${this.baseURL}sprays`, { + async getSprays() { + const data = await axios.get(`${this.baseURL}sprays`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of all spray levels * @returns {Promise>} A list of all Sprays */ - getSprayLevels() { - return axios.get(`${this.baseURL}sprays/levels`, { + async getSprayLevels() { + const data = await axios.get(`${this.baseURL}sprays/levels`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested spray * @param {string} uuid Spray UUID * @returns {Promise} Spray Object */ - getSpraybyUuid(uuid) { - return axios.get(`${this.baseURL}sprays/${uuid}`, { + async getSpraybyUuid(uuid) { + const data = await axios.get(`${this.baseURL}sprays/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested spray level * @param {string} uuid Spray Level UUID * @returns {Promise} Spray Level Object */ - getSprayLevelbyUuid(uuid) { - return axios.get(`${this.baseURL}sprays/levels/${uuid}`, { + async getSprayLevelbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}sprays/levels/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Theme Endpoints /** * Returns data and assets of all themes * @returns {Promise>} A list of all Themes */ - getThemes() { - return axios.get(`${this.baseURL}themes`, { + async getThemes() { + const data = await axios.get(`${this.baseURL}themes`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested theme * @param {string} uuid Theme UUID * @returns {Promise} Theme Object */ - getThemebyUuid(uuid) { - return axios.get(`${this.baseURL}themes/${uuid}`, { + async getThemebyUuid(uuid) { + const data = await axios.get(`${this.baseURL}themes/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } //Weapon Endpoints /** * Returns data and assets of all weapons * @returns {Promise>} A list of all Weapons */ - getWeapons() { - return axios.get(`${this.baseURL}weapons`, { + async getWeapons() { + const data = await axios.get(`${this.baseURL}weapons`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of all weapon skins * @returns {Promise>} A list of all Weapons */ - getWeaponsSkins() { - return axios.get(`${this.baseURL}weapons/skins`, { + async getWeaponsSkins() { + const data = await axios.get(`${this.baseURL}weapons/skins`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of all weapon skin chromas * @returns {Promise>} A list of all Weapon Skins Chromas */ - getWeaponSkinChromas() { - return axios.get(`${this.baseURL}weapons/skinchromas`, { + async getWeaponSkinChromas() { + const data = await axios.get(`${this.baseURL}weapons/skinchromas`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of all weapon skin levels * @returns {Promise>} A list of all Weapon Skin Levels */ - getWeaponSkinLevels() { - return axios.get(`${this.baseURL}weapons/skinlevels`, { + async getWeaponSkinLevels() { + const data = await axios.get(`${this.baseURL}weapons/skinlevels`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requeted weapon * @param {string} uuid Weapon UUID * @returns {Promise} Weapon Object */ - getWeaponbyUuid(uuid) { - return axios.get(`${this.baseURL}weapons/${uuid}`, { + async getWeaponbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}weapons/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requested weapon skin * @param {string} uuid Weapon Skin UUID * @returns {Promise} Weapon Skin Object */ - getWeaponSkinbyUuid(uuid) { - return axios.get(`${this.baseURL}weapons/skins/${uuid}`, { + async getWeaponSkinbyUuid(uuid) { + const data = await axios.get(`${this.baseURL}weapons/skins/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requeted weapon skin chroma * @param {string} uuid Weapon Skin Chroma UUID * @returns {Promise} Weapon Skin Chroma Object */ - getWeaponSkinChromaByUuid(uuid) { - return axios.get(`${this.baseURL}weapons/skinchromas/${uuid}`, { + async getWeaponSkinChromaByUuid(uuid) { + const data = await axios.get(`${this.baseURL}weapons/skinchromas/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } /** * Returns data and assets of the requeted weapon skin level * @param {string} uuid Weapon Skin Level UUID * @returns {Promise} Weapon Skin Level Object */ - getWeaponSkinLevelByUuid(uuid) { - return axios.get(`${this.baseURL}weapons/skinlevels/${uuid}`, { + async getWeaponSkinLevelByUuid(uuid) { + const data = await axios.get(`${this.baseURL}weapons/skinlevels/${uuid}`, { params: { language: this.language }, }); + return data.data.data; } } -module.exports = assetsAPI; +module.exports = Content; From b1754991bfbbc90b11056295c0857a49c1cd391b Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 26 Apr 2022 14:34:19 +1200 Subject: [PATCH 4/6] tidy up content api --- docs/{ContentApi.md => ContentAPI.md} | 85 ++++++------- index.js | 2 +- src/{contentApi.js => ContentAPI.js} | 167 ++++++++++++++++++-------- 3 files changed, 162 insertions(+), 92 deletions(-) rename docs/{ContentApi.md => ContentAPI.md} (60%) rename src/{contentApi.js => ContentAPI.js} (89%) diff --git a/docs/ContentApi.md b/docs/ContentAPI.md similarity index 60% rename from docs/ContentApi.md rename to docs/ContentAPI.md index 107e0e2..5bdab41 100644 --- a/docs/ContentApi.md +++ b/docs/ContentAPI.md @@ -1,16 +1,16 @@ # Content API -_This is an API wrapper for the_ [_valorant-api.com_](https://valorant-api.com) _API_ +This is an API wrapper for [valorant-api.com](https://valorant-api.com). This API is separate from the in-game APIs and is managed by a third party. #### Getting Started: -First you need to import the Content module and the Language Module. This is how it works: +First you need to import the ContentAPI module and the Language Module. ```javascript -const { Content, Languages } = require("@liamcottle/valorant.js"); +const { ContentAPI, Languages } = require("@liamcottle/valorant.js"); ``` -Next, you need to create an Content instance. Here you have the possibility to choose the Language in which the data will be delivered. By deafult the language is set to English. Here is a list of all available languages: +Next, you need to create a ContentAPI instance. You can optionally provide the Language the data should be returned in. By default, the language is set to English. Here is a list of all available languages: | **Languages** | | :-----------------: | @@ -33,7 +33,7 @@ Next, you need to create an Content instance. Here you have the possibility to c | Chinese_Traditional | ```js -const content = new ContentAPI(languages.English); +const content = new ContentAPI(Languages.English); ``` After you have created the ContentAPI instance you can start fetching data. For this you can either use _async/await_ or _.then_ this works as follows: @@ -55,26 +55,29 @@ content.getAgents().then((data) => { }); ``` -Here is a example on how to get the Daily Store of a Player and then get the Asset Data using the ContentAPI and the [ClientAPI](https://github.com/liamcottle/valorant.js#readme) this Package provides. +Here is an example of how to get a players' Daily Store and then fetch the Asset Data using the ContentAPI. ```js -//import modules -const { API, Content, languages, Regions } = require("@liamcottle/valorant.js"); +// import modules +const { API, ContentAPI, Languages, Regions } = require("@liamcottle/valorant.js"); -//initiate the API and the Content Module +// initiate the API and the ContentAPI Module const client = new API(Regions.EU); -const content = new Content(languages.English); +const content = new ContentAPI(Languages.English); -//authorize using the ClientAPI +// authorize using the ClientAPI client.authorize("username", "password").then(() => { client.getPlayerStoreFront(client.user_id).then(async (response) => { - //get assets for the first Skin in the Store - const item1 = await content.getWeaponSkinLevelbyUuid( - response.data.SkinsPanelLayout.SingleItemOffers[0] + + // get assets for the first Skin in the Store + const item1 = await content.getWeaponSkinLevelByUuid( + response.data.SkinsPanelLayout.SingleItemOffers[0] ); + + // log item + console.log(item1); + }); - //log item - console.log(item1); }); ``` @@ -82,69 +85,69 @@ Here is a list of all available Endpoints for the ContentAPI: - **[Agents](https://dash.valorant-api.com/endpoints/agents)** - getAgents() - - getAgentsbyUuid(_uuid_) + - getAgentsByUuid(_uuid_) - **[Buddies](https://dash.valorant-api.com/endpoints/buddies)** - getBuddies() - getBuddyLevels() - - getBuddybyUuid(_uuid_) - - getBuddyLevelbyUuid(_uuid_) + - getBuddyByUuid(_uuid_) + - getBuddyLevelByUuid(_uuid_) - **[Bundles](https://dash.valorant-api.com/endpoints/bundles)** - getBundles() - - getBundlebyUuid(_uuid_) + - getBundleByUuid(_uuid_) - **[Ceremonies](https://dash.valorant-api.com/endpoints/ceremonies)** - getCeremonies() - - getCeremonybyUuid(_uuid_) + - getCeremonyByUuid(_uuid_) - **[Competitive Tiers](https://dash.valorant-api.com/endpoints/competitivetiers)** - getCompetitiveTiers() - - getCompetitiveTierbyUuid(_uuid_) -- **[Content Tiers](https://dash.valorant-api.com/endpoints/contenttiers)** + - getCompetitiveTierByUuid(_uuid_) +- **[ContentAPI Tiers](https://dash.valorant-api.com/endpoints/contenttiers)** - getContentTiers() - - getContentTierbyUuid(_uuid_) + - getContentTierByUuid(_uuid_) - **[Contracts](https://dash.valorant-api.com/endpoints/contracts)** - getContracts() - - getContractbyUuid(_uuid_) + - getContractByUuid(_uuid_) - **[Currencies](https://dash.valorant-api.com/endpoints/currencies)** - getCurrencies() - - getCurrencybyUuid(_uuid_) + - getCurrencyByUuid(_uuid_) - **[Events](https://dash.valorant-api.com/endpoints/events)** - getEvents() - - getEventbyUuid(_uuid_) + - getEventByUuid(_uuid_) - **[Gamemodes](https://dash.valorant-api.com/endpoints/gamemodes)** - getGamemodes() - getGamemodeEquippables() - - getGamemodebyUuid(_uuid_) - - getGamemodeEquippablebyUuid(_uuid_) + - getGamemodeByUuid(_uuid_) + - getGamemodeEquippableByUuid(_uuid_) - **[Gear](https://dash.valorant-api.com/endpoints/gear)** - getGear() - - getGearbyUuid(_uuid_) + - getGearByUuid(_uuid_) - **[Maps](https://dash.valorant-api.com/endpoints/maps)** - getMaps() - - getMapbyUuid(_uuid_) + - getMapByUuid(_uuid_) - **[Player Cards](https://dash.valorant-api.com/endpoints/playercards)** - getPlayerCards() - - getPlayerCardbyUuid(_uuid_) + - getPlayerCardByUuid(_uuid_) - **[Player Titles](https://dash.valorant-api.com/endpoints/playertitles)** - getPlayerTitles() - - getPlayerTitlebyUuid(_uuid_) + - getPlayerTitleByUuid(_uuid_) - **[Seasons](https://dash.valorant-api.com/endpoints/seasons)** - getSeasons() - getCompetitiveSeasons() - - getSeasonbyUuid(_uuid_) - - getCompetitiveSeasonbyUuid(_uuid_) + - getSeasonByUuid(_uuid_) + - getCompetitiveSeasonByUuid(_uuid_) - **[Sprays](https://dash.valorant-api.com/endpoints/sprays)** - getSprays() - - getSpraybyUuid(_uuid_) + - getSprayByUuid(_uuid_) - **[Themes](https://dash.valorant-api.com/endpoints/themes)** - getThemes() - - getThemebyUuid(_uuid_) + - getThemeByUuid(_uuid_) - **[Weapons](https://dash.valorant-api.com/endpoints/weapons)** - getWeapons() - getWeaponSkins() - getWeaponSkinChromas() - get WeaponSkinLevels() - - getWeaponbyUuid(_uuid_) - - getWeaponSkinbyUuid(_uuid_) - - getWeaponSkinChromabyUuid(_uuid_) - - getWeaponSkinLevelbyUuid(_uuid_) + - getWeaponByUuid(_uuid_) + - getWeaponSkinByUuid(_uuid_) + - getWeaponSkinChromaByUuid(_uuid_) + - getWeaponSkinLevelByUuid(_uuid_) _If you have any Issue or Suggestion please open an Issue on the [Github Repository](https://github.com/liamcottle/valorant.js) or join the [Discord Server](https://discord.gg/HUFEkChRpP)_ diff --git a/index.js b/index.js index 3b9c2e9..f9ae7d1 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,6 @@ module.exports = { Regions: require("./src/regions"), Tiers: require("./src/tiers"), LocalRiotClientAPI: require("./src/LocalRiotClientAPI"), - Content: require("./src/contentApi"), + ContentAPI: require("./src/ContentAPI"), Languages: require("./src/languages"), }; diff --git a/src/contentApi.js b/src/ContentAPI.js similarity index 89% rename from src/contentApi.js rename to src/ContentAPI.js index fe75d9e..65da525 100644 --- a/src/contentApi.js +++ b/src/ContentAPI.js @@ -3,16 +3,18 @@ const axios = require("axios").default; const languages = require("./languages"); -class Content { +class ContentAPI { /** - * Initialize the Assets API using https://valorant-api.com/ - * @param {string} language The language of the output + * Initialize the Content API using https://valorant-api.com/ + * @param {string} language The language you want the content to be returned in */ constructor(language = languages.English) { this.language = language; this.baseURL = "https://valorant-api.com/v1/"; } - //agent Endpoints + + // agent Endpoints + /** * Get a list of all Agents * @returns {Promise>} A list of all Agents @@ -23,18 +25,21 @@ class Content { }); return data.data.data; } + /** * Get a specific Agent by UUID - * @param {sting} uuid The UUID of the Agent + * @param {string} uuid The UUID of the Agent * @returns {Promise} Agent Object */ - async getAgentbyUuid(uuid) { + async getAgentByUuid(uuid) { const data = await axios.get(`${this.baseURL}agents/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Buddies Endpoints + + // Buddies Endpoints + /** * Get a list of all Buddies * @returns {Promise>} A list of all Buddies @@ -45,6 +50,7 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of all weapon buddy levels * @returns {Promise>} A list of all Buddy Levels @@ -55,28 +61,32 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested weapon buddy * @param {string} uuid The UUID of the Buddy * @returns {Promise} Buddy Object */ - async getBuddybyUuid(uuid) { + async getBuddyByUuid(uuid) { const data = await axios.get(`${this.baseURL}buddies/${uuid}`, { params: { language: this.language }, }); return data.data.data; } + /** * Returns data and assets of the requested weapon buddy level - * @param {sting} uuid Buddy UUID + * @param {string} uuid Buddy UUID * @returns {Promise} BuddyLevel Object */ - async getBuddyLevelbyUuid(uuid) { + async getBuddyLevelByUuid(uuid) { const data = await axios.get(`${this.baseURL}buddies/levels/${uuid}`, { params: { language: this.language }, }); } - //Bundle Endpoints + + // Bundle Endpoints + /** * Returns a list of all Bundles * @returns {Promise>} A list of all Bundles @@ -87,18 +97,21 @@ class Content { }); return data.data.data; } + /** - *Returns data and assets of the requested bundle - * @param {sting} uuid Bundle UUID + * Returns data and assets of the requested bundle + * @param {string} uuid Bundle UUID * @returns {Promise} Bundle Object */ - async getBundlebyUuid(uuid) { + async getBundleByUuid(uuid) { const data = await axios.get(`${this.baseURL}bundles/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //ceremony Endpoints + + // Ceremony Endpoints + /** * Returns data and assets of all ceremonies * @returns {Promise>} A list of all Ceremonies @@ -109,18 +122,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested ceremony * @param {string} uuid Ceremony UUID * @returns {Promise} Ceremony Object */ - async getCeremonybyUuid(uuid) { + async getCeremonyByUuid(uuid) { const data = await axios.get(`${this.baseURL}ceremonies/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Competitive Tiers Endpoints + + // Competitive Tiers Endpoints + /** * Returns data and assets of all competitive tiers * @returns {Promise>} A list of all Competitive Tiers @@ -131,18 +147,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets the requested competitive tier table * @param {string} uuid Competitive Tier UUID * @returns {Promise} CompetitiveTier Object */ - async getCompetitiveTierbyUuid(uuid) { + async getCompetitiveTierByUuid(uuid) { const data = axios.get(`${this.baseURL}competitivetiers/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Content Tiers Endpoints + + // Content Tiers Endpoints + /** * Returns data and assets of all content tiers * @returns {Promise>} A list of all Content Tiers @@ -153,18 +172,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets for the requested content tier * @param {string} uuid Content Tier UUID * @returns {Promise} ContentTier Object */ - async getContentTierbyUuid(uuid) { + async getContentTierByUuid(uuid) { const data = await axios.get(`${this.baseURL}contenttiers/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Contract Endpoints + + // Contract Endpoints + /** * Returns data and assets of all contracts * @returns {Promise>} A list of all Contracts @@ -175,18 +197,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets the requested contract * @param {string} uuid Contract UUID * @returns {Promise} Contract Object */ - async getContractbyUuid(uuid) { + async getContractByUuid(uuid) { const data = await axios.get(`${this.baseURL}contracts/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Currencies Endpoints + + // Currencies Endpoints + /** * Returns data and assets of all in-game currencies * @returns {Promise>} A list of all Currencies @@ -197,18 +222,20 @@ class Content { }); return data.data.data; } + /** - *Returns data and assets the requested in-game currency + * Returns data and assets the requested in-game currency * @param {string} uuid Currency UUID * @returns {Promise} Currency Object */ - async getCurrencybyUuid(uuid) { + async getCurrencyByUuid(uuid) { const data = await axios.get(`${this.baseURL}currencies/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Events Endpoints + + // Events Endpoints /** * Returns data and assets of all events * @returns {Promise>} A list of all Events @@ -219,18 +246,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets the requested event * @param {string} uuid Event UUID * @returns {Promise} Event Object */ - async getEventbyUuid(uuid) { + async getEventByUuid(uuid) { const data = await axios.get(`${this.baseURL}events/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Gamemode Endpoints + + // Gamemode Endpoints + /** * Returns data and assets of all gamemodes * @returns {Promise>} A list of all Gamemodes @@ -241,6 +271,7 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of all gamemode equippables * @returns {Promise>} A list of all Gamemode Equippables @@ -251,23 +282,25 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested gamemode * @param {string} uuid * @returns {Promise} Gamemode Object */ - async getGameModebyUuid(uuid) { + async getGameModeByUuid(uuid) { const data = await axios.get(`${this.baseURL}gamemodes/${uuid}`, { params: { language: this.language }, }); return data.data.data; } + /** * Returns data and assets of the requested gamemode equippable * @param {string} uuid Gamemode Equippable UUID * @returns {Promise} Gamemode Equippable Object */ - async getGamemodeEquippablebyUuid(uuid) { + async getGamemodeEquippableByUuid(uuid) { const data = await axios.get( `${this.baseURL}gamemodes/equippables/${uuid}`, { @@ -276,7 +309,9 @@ class Content { ); return data.data.data; } - //Gear Endpoints + + // Gear Endpoints + /** * Returns data and assets of all gear * @returns {Promise>} A list of all Gear @@ -287,18 +322,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested gear * @param {string} uuid Gear UUID * @returns {Promise} Gear Object */ - async getGearbyUuid(uuid) { + async getGearByUuid(uuid) { const data = await axios.get(`${this.baseURL}gear/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Map Endpoints + + // Map Endpoints + /** * Returns data and assets of all maps * @returns {Promise>} A list of all Maps @@ -309,18 +347,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested map * @param {string} uuid Map UUID * @returns {Promise} Map Object */ - async getMapbyUuid(uuid) { + async getMapByUuid(uuid) { const data = await axios.get(`${this.baseURL}maps/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Player Cards Endpoints + + // Player Cards Endpoints + /** * Returns data and assets of all player cards * @returns {Promise>} A list of all Player Cards @@ -331,18 +372,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested player card * @param {string} uuid Player Card UUID * @returns {Promise} Player Card Object */ - async getPlayerCardbyUuid(uuid) { + async getPlayerCardByUuid(uuid) { const data = await axios.get(`${this.baseURL}playercards/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Player Titles Endpoints + + // Player Titles Endpoints + /** * Returns data and assets of all player titles * @returns {Promise>} A list of all Player Titles @@ -353,18 +397,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested player title * @param {string} uuid Player Title UUID * @returns {Promise} Player Title Object */ - async getPlayerTitlebyUuid(uuid) { + async getPlayerTitleByUuid(uuid) { const data = await axios.get(`${this.baseURL}playertitles/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Seasons Endpoints + + // Seasons Endpoints + /** * Returns data and assets of all seasons * @returns {Promise>} A list of all Seasons @@ -375,6 +422,7 @@ class Content { }); return data.data.data; } + /** * Returns data of all competitive seasons * @returns {Promise>} A list of all Competitive Seasons @@ -385,29 +433,33 @@ class Content { }); return data.data.data; } + /** * Returns data of the requested season * @param {string} uuid Season UUID * @returns {Promise} Season Object */ - async getSeasonbyUuid(uuid) { + async getSeasonByUuid(uuid) { const data = await axios.get(`${this.baseURL}seasons/${uuid}`, { params: { language: this.language }, }); return data.data.data; } + /** * Returns data of the requested competitive season * @param {string} uuid Competitive Season UUID * @returns {Promise} Competitive Season Object */ - async getCompetitiveSeasonbyUuid(uuid) { + async getCompetitiveSeasonByUuid(uuid) { const data = await axios.get(`${this.baseURL}seasons/competitive/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Spray Endpoints + + // Spray Endpoints + /** * Returns data and assets of all sprays * @returns {Promise>} A list of all Seasons @@ -418,6 +470,7 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of all spray levels * @returns {Promise>} A list of all Sprays @@ -428,29 +481,33 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested spray * @param {string} uuid Spray UUID * @returns {Promise} Spray Object */ - async getSpraybyUuid(uuid) { + async getSprayByUuid(uuid) { const data = await axios.get(`${this.baseURL}sprays/${uuid}`, { params: { language: this.language }, }); return data.data.data; } + /** * Returns data and assets of the requested spray level * @param {string} uuid Spray Level UUID * @returns {Promise} Spray Level Object */ - async getSprayLevelbyUuid(uuid) { + async getSprayLevelByUuid(uuid) { const data = await axios.get(`${this.baseURL}sprays/levels/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Theme Endpoints + + // Theme Endpoints + /** * Returns data and assets of all themes * @returns {Promise>} A list of all Themes @@ -461,18 +518,21 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requested theme * @param {string} uuid Theme UUID * @returns {Promise} Theme Object */ - async getThemebyUuid(uuid) { + async getThemeByUuid(uuid) { const data = await axios.get(`${this.baseURL}themes/${uuid}`, { params: { language: this.language }, }); return data.data.data; } - //Weapon Endpoints + + // Weapon Endpoints + /** * Returns data and assets of all weapons * @returns {Promise>} A list of all Weapons @@ -483,6 +543,7 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of all weapon skins * @returns {Promise>} A list of all Weapons @@ -493,6 +554,7 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of all weapon skin chromas * @returns {Promise>} A list of all Weapon Skins Chromas @@ -503,6 +565,7 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of all weapon skin levels * @returns {Promise>} A list of all Weapon Skin Levels @@ -513,28 +576,31 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requeted weapon * @param {string} uuid Weapon UUID * @returns {Promise} Weapon Object */ - async getWeaponbyUuid(uuid) { + async getWeaponByUuid(uuid) { const data = await axios.get(`${this.baseURL}weapons/${uuid}`, { params: { language: this.language }, }); return data.data.data; } + /** * Returns data and assets of the requested weapon skin * @param {string} uuid Weapon Skin UUID * @returns {Promise} Weapon Skin Object */ - async getWeaponSkinbyUuid(uuid) { + async getWeaponSkinByUuid(uuid) { const data = await axios.get(`${this.baseURL}weapons/skins/${uuid}`, { params: { language: this.language }, }); return data.data.data; } + /** * Returns data and assets of the requeted weapon skin chroma * @param {string} uuid Weapon Skin Chroma UUID @@ -546,6 +612,7 @@ class Content { }); return data.data.data; } + /** * Returns data and assets of the requeted weapon skin level * @param {string} uuid Weapon Skin Level UUID @@ -559,4 +626,4 @@ class Content { } } -module.exports = Content; +module.exports = ContentAPI; From 7c8cc42429274c93449e69b20c991386db1f5ae8 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 26 Apr 2022 14:36:58 +1200 Subject: [PATCH 5/6] add comments to modules --- index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f9ae7d1..2d1786f 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,16 @@ module.exports = { + + // Internal Game APIs API: require("./src/api"), - Maps: require("./src/maps"), - Regions: require("./src/regions"), - Tiers: require("./src/tiers"), LocalRiotClientAPI: require("./src/LocalRiotClientAPI"), + + // Third Party APIs ContentAPI: require("./src/ContentAPI"), + + // Static Content Languages: require("./src/languages"), + Maps: require("./src/maps"), + Regions: require("./src/regions"), + Tiers: require("./src/tiers"), + }; From 00aef159ee82c86b71005f2ae6d245f55ee3144c Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 26 Apr 2022 14:41:46 +1200 Subject: [PATCH 6/6] add link to content api docs in readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 27a51ca..f62fcec 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ donate bitcoin

-This is an **unofficial** NodeJS library for interacting with the [VALORANT](https://playvalorant.com/) APIs used in game. +This is an **unofficial** NodeJS library for interacting with the [VALORANT](https://playvalorant.com/) APIs used in game. It also serves as a wrapper around third party APIs that provide game content such as maps, player cards and weapons. ## Install @@ -225,6 +225,10 @@ Below is a list of API calls that are implemented in this library. - [x] `getPlayers(playerIds)` - [x] `getStoryContractDefinitions()` +# Content API + +Check out the [Content API Docs](./docs/ContentAPI.md) if you're wanting to fetch game assets such as Maps, Player Cards and Weapons. + # Local Riot Client API If you're looking for information on how to interact with `RiotClientServices.exe`, such as intercepting requests, take a look at the documentation in [RiotClientServices.md](./docs/RiotClientServices.md)