udwio/alpine-chi-poppet

PHP Client that consumes the Path of Exile Developer API. Alpine Chi Poppet is an anagram of `php poe api client`

v0.0.2 2019-11-25 12:19 UTC

This package is auto-updated.

Last update: 2024-04-13 18:23:19 UTC


README

Description

A library written in PHP that retrieves data from the public Path of Exile API.

The name is an anagram for php-poe-api-client

There is a top level class source/AlpineChiPoppet/AlpineChiPoppet.php which gives synchronous access to the lib and some handy helpers.

To get Async access with finer grained control, there are classes for each endpoint in source/AlpineChiPoppet/<endpoint>/<endpoint.php> with the appropriate methods. #TODO since this will get rate limited hard

Standalone Installation

    cd /path/to/project
   composer require udwio/alpine-chi-poppet

Laravel Installation

Quick Start

    # Run the frontend cli for quick and dirty examples of how to use the library
    php scripts/acp-cli.php examples

    # you can execute a manual query for testing the live API with the CLI by following the help directions
    php scripts/acp-cli.php run --help
    
    # e.g.
    php scripts/acp-cli.php run -i "SSF+Heist+HC" -l 200 -o 0 -u true | less

AlpineChiPoppet class and Helper Methods

These Helper methods can be accessed when you include the AlpineChiPoppet class. The AlpineChiPoppet class provides quick access to the rest of the library. To get finer grained control include the underlying endpoint classes instead. All of these methods are execute synchronously i.e. they are blocking.

    /** /ladders/ **/
    public function getLeagueLadder(Array $a): array;
    public function getLabyrinthLadder(Array $a): array;
    public function getTempSCLadder(): array;
    public function getTempHCLadder(): array;
    public function getTempSSFSCLadder(): array;
    public function getTempSSFHCLadder(): array;
    public function getCsvLadder(Array $a, String $filePath);

    /** /seasons/ **/
    public function listSeasons(): Array;

    /** /character-window/ **/
    public function getCharacters(Array $pConf): string; 
    public function getItems(): string; // not implemented
    public function getPassiveSkills(): string; // not implemented
    public function getStashItems(): string; // not implemented
    public function getMtxStashItems(): string; // not implemented
    public function getAccountNameByCharacter(): string; // not implemented

    /** /pvp-matches/ **/
    public function getPvPMatches(): string; /// not implemented

    /** /public-stash-tabs/ **/
    public function getPublicStashTabs(): string; // not implemented

    /** /shop/microtransactions/specials **/
    public function getMtxSpecials(): string; //not implemented

    /** /trade/data/ **/
    public function getTradeDataLeagues(): string; // not implemented
    public function getTradeDataItems(): string; // not implemented
    public function getTradeDataStats(): string; // not implemented
    public function getTradeDataStatic(): string; // not implemented

    /** /trade/search/ **/
    public function postTradeSearch(); //not implemented

    /** /trade/fetch/ **/
    public function getResultsByString(): string; //not implemented

    /** /trade/ignore/ **/
    public function getIgnoredAccounts(): string; // not implemented
    public function putIgnoreAccount(); // not implemented
    public function deleteIgnoredAccount(); // not implemented

    /** /guild/ **/
    public function getGuildStashHistory(): string; //not implemented

    /** /leagues/ **/
    public function listLeagues(Array $a);
    
    /** /league-rules/ **/
    public function getLeagueRules(): string;
    public function getSingleRule(Array $a): array;

Standalone Usage

In the source directory the requests are grouped by endpoint. For Ex: https://api.pathofexile.com/ladders/ is in source/AlpineChiPoppet/Ladders/

Example usage in a PHP project

use AlpineChiPoppet\AlpineChiPoppet;

class MyExampleClass 
{
    $config = 'path/to/config/file'; // default is supplied in vendor directory.
    $acp = new AlpineChiPoppet($config);

    $results = $acp->getTempHCLadder();

    print($results);

}

Example console output


Configuration

Defaults can be found in ./source/AlpineChiPoppet/Support/Config/acp.php

POESESSID

WARNING DO NOT COMMIT THIS VALUE TO YOUR VCS

Some of the endpoints require sending the POESESSID cookie with the requests for authentication.

  • Make your own copy of the config file. eg. cp source/AlpineChiPoppet/Config/acp.php tmp/acp-with-auth.php
  • Point your app to the new config file. eg. if using the test cli tool use the -c option php scripts/acp.php command -c /path/to/config/file
  • Log into Path of Exile site with a browser.
  • Find the cookie called POESESSID. this is browser specific and you need to look this up yourself soomehow.
  • Copy the value for this cookie into the new config file under the value poe_session_id
  • change the value for scheme to https

In Laravel projects publish this file to the config folder so it will take precedence over the default config file in vendor/udwio/AlpineChiPoppet/.... .

    php artisan vendor:publish --provider=AlpineChiPoppet

Cache

If you choose to use the cache options, they can be enabled in the AlpineChiPoppet config file.

MAKE SURE YOUR VERSION OF PHP HAS THE CORRECT EXTENSIONS ENABLED

Getting Help

Inspect the scripts/acp-cli.php script for basic usage and the tests in the test directory to get help with how to use the library.

Run the testing suite

composer run tests

in verbose mode

composer run tests-verbose