1.10.1 • Published 11 months ago

poe-trade-fetch v1.10.1

Weekly downloads
-
License
-
Repository
github
Last release
11 months ago

PoE Trade Fetch Documentation

This document provides an in-depth overview of the PoE Trade Fetch library, which you can use to interact with the Path of Exile (PoE) trading API.

Table of Contents

Overview

PoE Trade Fetch is a JavaScript library designed to interact with the PoE in-game trading platform API. It simplifies the process of fetching item data, handling rate limits, and parsing search results in a structured way.

Features

  • API Integration: Easily connect to the PoE Trade API.
  • Rate Limit Handling: Built-in support for managing request delays to avoid rate limiting.
  • Flexible Query: Customize searches based on item attributes.
  • Multiple Request Types: Separate methods for initial searches and detailed follow-up requests.

Prerequisites

  • Node.js version 12 or above.
  • A valid POESESSID (optional, increases request limit).
  • Basic knowledge of JavaScript and asynchronous programming.

Installation

You can install the package using npm:

npm install poe-trade-fetch

Usage

Initialization

First, import the necessary components and initialize the library with your settings:

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

const poeTradeFetch = PoeTradeFetch.createInstance({
  leagueName: LEAGUES_NAMES.Current,  // Default: 'Standard'
  userAgent: 'My PoE App  your@mail.kek',
  realm: REALMS.pc,                   // Default: pc
  POESESSID: 'Your POESESSID',         // Optional: for increased request rate
  useRateLimitDelay: true             // Default: true 
});
await poeTradeFetch.update();

Making Requests

First Request

Perform an initial search request using your custom query:

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

const { result, id } = await poeTradeFetch.firsRequest(RequestBody);

// Ensure a maximum of 10 identifiers, as PoE API limits the request
const identifiers = result.length > 10 ? result.slice(0, 10) : result;

Second Request

Fetch detailed trade data for the listed item identifiers:

const { result: secondResult } = await poeTradeFetch.secondRequest(identifiers, id);
console.log('Trade Data Items:', secondResult);

// Example: accessing price details
const numberPrice = secondResult[0].listing.price.amount;
const currencyPrice = secondResult[0].listing.price.currency;

API Reference

  • PoeTradeFetch(options)
    Initializes the API client. Options include:

    • leagueName (default: LEAGUES_NAMES.Standard)
    • userAgent
    • realm (default: REALMS.pc)
    • POESESSID (optional)
  • update()
    Fetches necessary metadata and updates the internal state.

  • firsRequest(RequestBodyType)
    Executes the initial search request. Returns object with:

    • id: identifier for the request
    • result: list of item identifiers
  • secondRequest(identifiers, id)
    Fetches detailed trade information based on identifiers and request ID.

  • httpRequest.getWaitTime(key)
    Returns the required delay time for the next request based on the rate limiting key.

Troubleshooting

  • Rate Limit Errors:
    Ensure you implement the proper delay between requests. If you experience rate limiting issues, consider adjusting your request intervals or using a valid POESESSID.

  • Invalid Query Responses:
    Double-check your query parameters. Consult the PoE Trade API documentation for valid parameter options.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a branch for your feature or bug fix.
  3. Write tests and ensure they pass.
  4. Submit a pull request with a detailed description of your changes.

License

This project is licensed under the MIT License. You can view the full license in the LICENSE file.

1.9.1

11 months ago

1.9.0

11 months ago

1.8.13

11 months ago

1.8.14

11 months ago

1.10.1

11 months ago

1.10.0

11 months ago

1.8.12

2 years ago

1.8.11

2 years ago

1.8.10

2 years ago

1.8.9

2 years ago

1.8.8

2 years ago

1.8.7

2 years ago

1.8.6

2 years ago

1.8.2

2 years ago

1.8.1

2 years ago

1.8.5

2 years ago

1.8.4

2 years ago

1.8.3

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.3.3

2 years ago

1.4.1

2 years ago

1.3.2

2 years ago

1.1.4

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.2.2

2 years ago

1.1.3

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.2

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago