1.8.11 • Published 1 month ago

poe-trade-fetch v1.8.11

Weekly downloads
-
License
-
Repository
github
Last release
1 month ago

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  your@mail.kek',
  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  your@mail.kek',
  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.

1.8.11

1 month ago

1.8.10

2 months ago

1.8.9

2 months ago

1.8.8

2 months ago

1.8.7

2 months ago

1.8.6

2 months ago

1.8.2

3 months ago

1.8.1

3 months ago

1.8.5

3 months ago

1.8.4

3 months ago

1.8.3

3 months ago

1.8.0

3 months ago

1.7.0

3 months ago

1.6.0

4 months ago

1.5.0

4 months ago

1.2.0

7 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.1

7 months ago

1.3.3

7 months ago

1.4.1

6 months ago

1.3.2

7 months ago

1.1.4

7 months ago

1.4.0

6 months ago

1.3.1

7 months ago

1.2.2

7 months ago

1.1.3

7 months ago

1.3.0

7 months ago

1.2.1

7 months ago

1.1.2

7 months ago

0.0.22

8 months ago

0.0.21

8 months ago

0.0.20

8 months ago

0.0.19

8 months ago

0.0.18

8 months ago

0.0.17

8 months ago

0.0.16

8 months ago

0.0.15

8 months ago

0.0.14

8 months ago

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago