npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

poe-trade-fetch

v1.8.12

Published

poe trade fetch

Downloads

30

Readme

PoE Trade Fetch

PoE Trade Fetch is a JavaScript library for interacting with the "Path of Exile" (PoE) in-game trading platform API. It allows you to retrieve item information.

Key Features

  • Perform a search for items on the PoE Trade API.

Installation

You can install PoE Trade Fetch via npm:

npm install poe-trade-fetch

Usage

import { LEAGUES_NAMES, RATE_LIMIT_STATE_KEYS, REALMS, PoeTradeFetch, RequestBodyType } from 'poe-trade-fetch';

const poeTradeFetch = new PoeTradeFetch({
  leagueName: LEAGUES_NAMES.Current, // League name (default is 'Standard')
  userAgent: 'My PoE App  [email protected]',
  realm: REALMS.pc, // Realm (default is pc)
});
await poeTradeFetch.update();

// Use the API to fetch data (example)
const tradeUrl = new URL('https://www.pathofexile.com/trade/search/Ancestor/EGmMQEKS5');
const tradeDataItems = await poeTradeFetch.poeTradeSearchUrl(tradeUrl, 'Your POESESSID');
console.log('Trade Data Items:', tradeDataItems.result);

// Another example
// I create a delay before the call, if you don't do the delay after a few requests you will get a RateLimit from the PoE API.
// My solution takes this into account, and if you have exceeded the limit,
// then poeTradeFetch will not issue the request and will simply throw this error: throw new Error('Rate limit exceeded');.
// So the request will not be made and you will not receive any restrictions on poe trade.
// Please note that if your IP address is being used by concurrent requests, you may still experience rate throttling.
// You can also set  POESESSID, this will increase the number of requests per minute.
// You also need to understand that different rate limits are possible for different API urls

const poeTradeFetch = new PoeTradeFetch({
  leagueName: LEAGUES_NAMES.Current, // League name (default is 'Standard')
  userAgent: 'My PoE App  [email protected]',
  realm: REALMS.pc, // Realm (default is pc)
  POESESSID: 'Your POESESSID',
});
await poeTradeFetch.update();

const firstDelay = poeTradeFetch.httpRequest.getWaitTime(RATE_LIMIT_STATE_KEYS.POE_API_FIRST_REQUEST);
await poeTradeFetch.httpRequest.delay(firstDelay);

const RequestBody: RequestBodyType = {
  query: {
    status: { option: 'online' },
    name: 'Prismweave',
    type: 'Rustic Sash',
    stats: [{ type: 'and', filters: [], disabled: false }],
  },
  sort: { price: 'asc' },
}; // just create you any query

const { result, id } = await poeTradeFetch.firsRequest(RequestBody);
// You take something like this response
// {
//  "id": "prX3f0",
//  "complexity": 6,
//  "result": [
//   "9b09e2b621794cd73804a1c27c3ab817b8d6467efdac1ec406944ca47c0324e7",
//   "7015ff5aad7940c0ca3b5ff76d1444c9ae3321ac3f7944a3ee5eedcf8349beba",
//      ...  another ids
//  ],
//  "total": 2053
// }
// if you give more than 10 IDs, the PoE API will give an error
const identifiers = result.length > 10 ? result.slice(0, 10) : result;

const secondDelay = poeTradeFetch.httpRequest.getWaitTime(RATE_LIMIT_STATE_KEYS.POE_API_SECOND_REQUEST);
await poeTradeFetch.httpRequest.delay(secondDelay);

// here you get information about 10 listings on poe trade
const { result: secondResult } = await poeTradeFetch.secondRequest(identifiers, id);
console.log('Trade Data Items:', secondResult);
const numberPrice = secondResult[0].listing.price.amount;
const currencyPrice = secondResult[0].listing.price.currency;

License

This project is licensed under the MIT License - see the LICENSE file for details.