@juice789/tf2items
Version:
tf2 item schema thingys
57 lines (45 loc) • 1.69 kB
JavaScript
import axios from 'axios'
const myAxios = axios.create()
myAxios.interceptors.response.use(res => res.data, Promise.reject.bind(Promise))
export const api = {}
api.getSchemaItems = ({ steamApiKey: key }) => (start) => myAxios({
method: 'get',
url: 'https://api.steampowered.com/IEconItems_440/GetSchemaItems/v1/',
params: {
key,
language: 'EN',
start
}
})
api.getSchemaOverview = ({ steamApiKey: key }) => () => myAxios({
method: 'get',
url: 'https://api.steampowered.com/IEconItems_440/GetSchemaOverview/v1/',
params: {
key,
language: 'EN'
}
})
api.getItemsGameUrl = ({ steamApiKey: key }) => () => myAxios({
method: 'get',
url: 'https://api.steampowered.com/IEconItems_440/GetSchemaURL/v1/',
params: {
key
}
})
api.getItemsGame = () => (url) => myAxios({
method: 'get',
url
})
api.fetchTfEnglish = () => () => myAxios({
method: 'get',
url: 'https://raw.githubusercontent.com/SteamDatabase/GameTracking-TF2/master/tf/resource/tf_english.txt'
})
api.fetchProtoObjDefs = () => () => myAxios({
method: 'get',
url: 'https://raw.githubusercontent.com/SteamDatabase/GameTracking-TF2/master/tf/resource/tf_proto_obj_defs_english.txt'
})
api.getAssetClassInfo = ({ steamApiKey }) => (ids, appId = 440) => myAxios({
method: 'get',
url: `https://api.steampowered.com/ISteamEconomy/GetAssetClassInfo/v1/?key=${steamApiKey}&appid=${appId}&language=EN&class_count=${ids.length}${ids.join('')}`
})
export const createApi = (options) => Object.fromEntries(Object.entries(api).map(([k, fn]) => [k, fn(options)]))