rayblair / spacetradersphp
An API Wrapper for spacetraders.io written in PHP
0.1.0
2021-03-24 21:48 UTC
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.2
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-25 15:42:28 UTC
README
An API Wrapper for spacetraders.io written in PHP.
Installation
You can install the package via composer:
composer require rayblair/spacetradersphp
Example
// Include composer autoload, if required require __DIR__ . '/vendor/autoload.php'; // Import the SpaceTradersPHP class use RayBlair\SpaceTradersPHP\SpaceTradersPHP; // Initial a client instance $client = new SpaceTradersPHP('token', 'username'); // Will return the game status echo $client->game->status()->status; // kill php script die();
Usage
// Include composer autoload, if required require 'vendor/autoload.php'; // Import the SpaceTradersPHP class use RayBlair\SpaceTradersPHP\SpaceTradersPHP; // Initial a client instance $client = new SpaceTradersPHP('token', 'username'); // Get Game Status $client->game->status(); // Create User Token $client->users->token('username'); // Show User $client->users->get('username'); // Get All Active Flight Plans $client->flightPlans->all('OE'); // Get existing Flight Plan $client->flightPlans->get('username', 'flight_plan_id'); // Create Flight Plan $client->flightPlans->create('username', 'ship_id', 'destination'); // Get available loans $client->loans->all(); // Get loans $client->loans->get('username'); // Takeout loan $client->loans->takeout('username', 'STARTUP'); // Payoff loan $client->loans->payoff('username', 'loan_id'); // Get Location $client->locations->get('OE-UC'); // Get Ships at Location $client->locations->ships('OE-UC'); // Get Locations in System $client->systems->all(); // Get Locations in System $client->systems->get('OE'); // Get Marketplace in Location $client->locations->marketplace('OE-UC'); // Purchase Order $client->orders->purchase('username', 'ship_id', 'FUEL', 20); // Sell Order $client->orders->sell('username', 'ship_id', 'FUEL', 20); // Show All Ships $client->ships->all(); // Show Player's Ships $client->ships->get(); // Get Ship by ID $client->ships->get('ship_id'); // Purchase Ship $client->ships->purchase('username', 'OE-PM-TR', 'JW-MK-I'); // Jettison Ship's Cargo $client->ships->jettison('username', 'ship_id', 'FUEL', 20); // Scrap Ship $client->ships->scrap('username', 'ship_id');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.