how to get items name #6
Replies: 20 comments
-
sorry, it's not a bug,please remove bug label |
Beta Was this translation helpful? Give feedback.
-
how did you get that item id? that is difficult to find. |
Beta Was this translation helpful? Give feedback.
-
there is my code import { AuthClient } from '@valapi/auth'
import { Client as WebClient } from '@valapi/web-client'
import { Region } from '@valapi/lib'
const config = {
region: Region.Default.Asia_Pacific,
throwOnError: true,
}
const authClient = new AuthClient(config)
const login = async () => {
await authClient.login('xxx', 'xxx')
}
const main = async () => {
await login()
const subject = authClient.getSubject()
const json = authClient.toJSON()
const webClient = new WebClient(config)
webClient.fromJSON(json)
const data = await webClient.Store.getStorefront(subject)
console.log(data.data.SkinsPanelLayout.SingleItemOffers[0])
}
main() |
Beta Was this translation helpful? Give feedback.
-
here you are, try it first maybe it doesn't work. const getOffers = await WebClient.Store.getOffers();
async function getOffersOf(ItemsId: string) {
let Store_Display_Name = "";
let Store_Display_Icon = "";
const GetWeaponSkinLevel = await ValorantApiCom.Weapons.getSkinLevels();
for (const _SkinLevel of GetWeaponSkinLevel.data.data) {
if (_SkinLevel.uuid === ItemsId) {
Store_Display_Name = _SkinLevel.displayName;
Store_Display_Icon = _SkinLevel.displayIcon;
break;
}
}
return {
Name: Store_Display_Name,
Icon: Store_Display_Icon
};
}
const AllOffers = (await WebClient.Store.getStorefront("subject")).data.SkinsPanelLayout.SingleItemOffers;
for (const ofItemID in AllOffers) {
const ItemID = AllOffers[ofItemID];
const _Offer = await getOffersOf(ItemID);
} |
Beta Was this translation helpful? Give feedback.
-
it's not work, this request https://pd.ap.a.pvp.net/store/v2/storefront/subject 400 status |
Beta Was this translation helpful? Give feedback.
-
maybe it need auth? |
Beta Was this translation helpful? Give feedback.
-
but there is not |
Beta Was this translation helpful? Give feedback.
-
there is my code now import { AuthClient } from '@valapi/auth'
import { Client as WebClient } from '@valapi/web-client'
import { Client as ValorantApi } from '@valapi/valorant-api.com'
import { Region } from '@valapi/lib'
const config = {
region: Region.Default.Asia_Pacific,
throwOnError: true,
}
const authClient = new AuthClient(config)
const login = async () => {
await authClient.login('xxx', 'xxx')
}
const main = async () => {
await login()
const subject = authClient.getSubject()
const json = authClient.toJSON()
const webClient = new WebClient(config)
const ApiClient = new ValorantApi({
language: 'zh-CN',
})
webClient.fromJSON(json)
// ApiClient.fromJSON(json)
const data = await webClient.Store.getStorefront(subject)
const getOffers = await webClient.Store.getOffers()
async function getOffersOf(ItemsId: string) {
let Store_Display_Name = ''
let Store_Display_Icon = ''
const GetWeaponSkinLevel = await ApiClient.Weapons.getSkinLevels()
for (const _SkinLevel of GetWeaponSkinLevel.data.data!) {
if (_SkinLevel.uuid === ItemsId) {
Store_Display_Name = _SkinLevel.displayName as string
Store_Display_Icon = _SkinLevel.displayIcon
break
}
}
return {
Name: Store_Display_Name,
Icon: Store_Display_Icon,
}
}
const AllOffers = (await webClient.Store.getStorefront('subject')).data.SkinsPanelLayout
.SingleItemOffers
for (const ofItemID in AllOffers) {
const ItemID = AllOffers[ofItemID]
const _Offer = await getOffersOf(ItemID)
console.log(_Offer)
}
}
main() |
Beta Was this translation helpful? Give feedback.
-
yes like that, |
Beta Was this translation helpful? Give feedback.
-
@KTNG-3 like this? but it still not working now |
Beta Was this translation helpful? Give feedback.
-
import { AuthClient } from "@valapi/auth";
import { Client as WebClient } from "@valapi/web-client";
import { Client as ValorantApi } from "@valapi/valorant-api.com";
import { Region } from "@valapi/lib";
const config = {
region: Region.Default.Asia_Pacific,
throwOnError: true
};
const authClient = new AuthClient(config);
const login = async () => {
await authClient.login("Username", "Password");
};
const main = async () => {
await login();
const subject = authClient.getSubject();
const webClient = WebClient.fromJSON(authClient.toJSON());
const ApiClient = new ValorantApi({
language: "zh-CN"
});
const data = await webClient.Store.getStorefront(subject);
// const getOffers = await webClient.Store.getOffers();
async function getOffersOf(ItemsId: string) {
let Store_Display_Name = "";
let Store_Display_Icon = "";
const GetWeaponSkinLevel = await ApiClient.Weapons.getSkinLevels();
if (GetWeaponSkinLevel.data.data) {
for (const _SkinLevel of GetWeaponSkinLevel.data.data) {
if (_SkinLevel.uuid === ItemsId) {
Store_Display_Name = _SkinLevel.displayName as string;
Store_Display_Icon = _SkinLevel.displayIcon;
break;
}
}
}
return {
Name: Store_Display_Name,
Icon: Store_Display_Icon
};
}
const AllOffers = data.data.SkinsPanelLayout
.SingleItemOffers;
for (const ofItemID in AllOffers) {
const ItemID = AllOffers[ofItemID];
const _Offer = await getOffersOf(ItemID);
console.log(_Offer);
}
};
main(); |
Beta Was this translation helpful? Give feedback.
-
is it work? |
Beta Was this translation helpful? Give feedback.
-
The code works fine, but the information is not the same as my store information |
Beta Was this translation helpful? Give feedback.
-
hmm, its seem a problem |
Beta Was this translation helpful? Give feedback.
-
I can't tell whether I got the wrong id or the id is wrongly mapped to the displayname |
Beta Was this translation helpful? Give feedback.
-
there is my log 89b68205-4fe5-2434-a731-e5a734bd4a7a Undercity Bulldog
5f059d7e-413c-445c-e36f-9a9791fba5b0 Origin Crescent Blade
33d3c906-4305-19cf-8770-1eb5207482cc Rush Judge
1b94d997-4db6-014f-4cb8-c1b4df7d7ebc Smite Judge |
Beta Was this translation helpful? Give feedback.
-
so you need "displayname" in your language |
Beta Was this translation helpful? Give feedback.
-
i find it const webClient = new WebClient(config)
webClient.fromJSON(authClient.toJSON()) This needs to be written in order to correctly set the region in config const webClient = WebClient.fromJSON(authClient.toJSON()); Writing config like this doesn't work |
Beta Was this translation helpful? Give feedback.
-
it is ok now, thx |
Beta Was this translation helpful? Give feedback.
-
i have got item id '167481de-4732-b44a-06ad-938625015abe' ,so how can i get this item name?
Beta Was this translation helpful? Give feedback.
All reactions