steamcommunity-inventory
Version:
A rate limit and response handler for steamcommunity inventories. - It's functional. - Will appreciate all feedback I can get
86 lines • 3.29 kB
TypeScript
import { AxiosInstance } from 'axios';
import Bottleneck from 'bottleneck';
import { Parser } from './Inventory/Parser';
import { EconItem } from './Inventory/types';
export declare type InventoryOptions<T> = {
steamID?: string;
formatter?: Formatter<T>;
headers?: Record<string, string>;
cookies?: string[];
minTime?: number;
maxConcurent?: number;
reservoir?: number;
reservoirRefreshAmount?: number;
reservoirRefreshInverval?: number;
axiosInstance?: AxiosInstance;
};
export declare type Formatter<T> = (econ: EconItem) => T;
export declare type GetInventoryParams = {
steamID: string;
appID: string;
contextID: string;
lastAssetId?: string;
count?: number;
language?: string;
};
export declare type FetchInventoryPageParams<T> = {
steamID: string;
appID: string;
contextID: string;
lastAssetId?: string;
count: number;
language?: string;
inventory?: T[];
};
/**
* Handles inventory requests to SteamCommunity.
*/
export declare class Inventory<TItem = EconItem> {
cookies?: string;
steamID?: string;
formatter?: Formatter<TItem>;
parser: Parser<TItem>;
headers?: Record<string, string>;
request: AxiosInstance;
limiter: Bottleneck;
/**
* @param {Object} options
* @param {string} options.steamID When passed with cookies,
* you don't have to rely on rate limit, steam lets you request your inventory freely
* @param {number} options.minTime @see https://github.com/SGrondin/bottleneck#constructor
* @param {number} options.maxConcurent @see https://github.com/SGrondin/bottleneck#constructor
* @param {number} options.reservoir @see https://github.com/SGrondin/bottleneck#constructor
* @param {number} options.reservoirRefreshAmount @see https://github.com/SGrondin/bottleneck#constructor
* @param {number} options.reservoirRefreshInverval @see https://github.com/SGrondin/bottleneck#constructor
* @param {'new'|'old'} options.method method we use for inventory
* @param {Function} options.formatter modifies econItem before being passed into then
* @param {Object} [options.headers]
*/
constructor(options?: InventoryOptions<TItem>);
/**
* Sets cookies to instance, in key=value format.
* @param {string[]} cookies
*/
setCookies(cookies: string[]): void;
/**
* Gets inventory from new endpoint that has better rate limit but less data.
* @param {string} steamID
* @param {string} appID
* @param {string} contextID
* @param {string} [start] from which assetID do you want to start
* @param {number} [count=Infinity] If set gets the exact amount of items,
* if `Infinity` gets all recursively,
* if `void` gets only the first 500
* @param {string} [language=english]
* @return {Promise<TItem[]>}
*/
get({ steamID, appID, contextID, lastAssetId, count, language, }: GetInventoryParams): Promise<TItem[]>;
private fetchInventoryPage;
private sendRequest;
/**
* Returns cookies in object for iterators.
* @return {Object}
*/
private getHeaders;
}
//# sourceMappingURL=Inventory.d.ts.map