A powerful spacetraders API
Project description
Autotraders
A spacetraders API focused on automation and ease of use
Usage
First you need a client, which can be generated
import requests
class BearerAuth(requests.auth.AuthBase):
def __init__(self, token):
self.token = token
def __call__(self, r):
r.headers["authorization"] = "Bearer " + self.token
return r
token = TOKEN_HERE
s = requests.Session()
s.auth = BearerAuth(token)
And now you're all set to use they actual API.
Ships
from autotraders.ship import Ship, get_all_ships
# create a session here
ship = Ship("SYMBOL-Here", session) # This makes an API request
ships = get_all_ships(session) # This also only makes one API request
ship.dock()
ship.refuel()
ship.orbit() # All these functions make API calls (one each), but the line below doesn't
print(ship.fuel.current + "/" + ship.fuel.total)
Contract
from autotraders.contract import Contract, get_all_contracts
# create a session here
contract = Contract("id-here", session)
contracts = get_all_contracts(session)
contract.accept()
print(contract.accepted) # True
contract.deliver("SHIP_SYMBOL", "ALUMINUM_ORE", 30)
contract.fulfill()
print(contract.fulfilled) # True
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
autotraders-0.3.1.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for autotraders-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27eed57d1f4a25e803b87d6151b44be9b2ee20600a0f608ac1d6954d194b56ce |
|
MD5 | 1bdffdf306a0ce159f251b86994104e6 |
|
BLAKE2b-256 | a1e0000f72e291ebb40285fd6988c76c8a6d15035bec5e50ea61a8e7e76c06f3 |