This is a rust API wrapper for https://spacetraders.io V2
Many of the client functions in this project are based on, or in some cases copied directly from, the work of https://github.com/bloveless/spacetraders-rs
Use the following example to get started.
```rust use spacedustrs::client::Client;
async fn main() -> Result<(), Box
// Setup Game Client
let http_client = spacedustrs::client::get_http_client(None);
// Register agent
let claim_agent_response = spacedustrs::client::claim_agent(
http_client,
"https://v2-0-0.alpha.spacetraders.io".to_string(),
"<4-8 character string>".to_string(),
"COMMERCE_REPUBLIC".to_string(),
)
.await.unwrap();
// Setup client using claimed agent
let client = Client::new(
http_client,
"https://v2-0-0.alpha.spacetraders.io".to_string(),
claim_agent_response.data.agent.symbol,
claim_agent_response.token,
);
// Get agent details to confirm working
match client.get_my_agent_details().await {
Ok(res) => {
println!("{:#?}", res);
}
Err(res_err) => {
println!("{:#?}", res_err);
}
}
Ok(())
} ```
Agent & Account
POST
/agentsspacedustrs::client::claim_agent(base_url: String, http_client: http_client, agent_symbol: String, agent_faction: String) -> responses::ClaimAgent
Systems
GET
/systemsClient.get_systems() -> responses::SystemsListResponse
GET
/systems/{systemSymbol}Client.get_system_info(system_symbol: String) -> responses::SystemInformationResponse
GET
/systems/{systemSymbol}/waypointsClient.get_system_waypoints(system_symbol: String) -> responses::SystemWaypointsResponse
GET
/systems/{systemSymbol}/waypoints/{waypointSymbol}Client.get_system_waypoint(system_symbol: String, waypoint_symbol: String) -> responses::SystemWaypointResponse
GET
/systems/{systemSymbol}/shipyards # view all shipyards in a systemClient.get_system_shipyards(system_symbol: String) -> responses::SystemShipyardsResponse
GET
/systems/{systemSymbol}/shipyards/{shipyardSymbol}Client.get_system_shipyard(system_symbol: String, shipyard_symbol: String) -> responses::SystemShipyardResponse
GET
/systems/{systemSymbol}/shipyards/{shipyardSymbol}/ships # view all ships for sell at a shipyardClient.get_shipyard_ships(system_symbol: String, shipyard_symbol: String) -> responses::ShipyardShipsResponse
GET
/systems/{systemSymbol}/markets # view all markets in a systemClient.get_system_markets(system_symbol: String) -> responses::SystemMarketsResponse
GET
/systems/{systemSymbol}/markets/{marketSymbol} # view all trades at a given marketClient.get_system_market(system_symbol: String, market_symbol: String) -> responses::SystemMarketResponse
Agent
GET
/my/agentClient.get_my_agent_details() -> responses::AgentDetails
Contracts
GET
/my/contractsClient.get_my_contracts() -> responses::ContractsResponse
GET
/my/contracts/{contractId}Client.get_my_contract(contract_id: String) -> responses::ContractResponse
POST
/my/contracts/{contractId}/acceptClient.get_my_contract(contract_id: String) -> responses::AcceptedContractResponse
Ships
GET
/my/shipsClient.get_my_ships() -> responses::ShipsResponse
GET
/my/ships/{shipSymbol}Client.get_my_ship(ship_id: String) -> responses::ShipResponse
POST
/my/ships/{shipSymbol}/chartClient.chart(ship_id: String) -> responses::ChartResponse
GET
/my/ships/{shipSymbol}/navigateClient.ship_navigation_status(ship_id: String) -> responses::NavigateResponse
POST
/my/ships/{shipSymbol}/navigate destination=destination_symbolClient.ship_navigation_status(ship_id: String, destination_symbol: String) -> responses::NavigateResponse
GET
/my/ships/{shipSymbol}/surveyClient.get_survey_cooldown(ship_id: String) -> responses::CooldownResponse
POST
/my/ships/{shipSymbol}/surveyClient.survey_surroundings(ship_id: String) -> responses::SurveyResponse
GET
/my/ships/{shipSymbol}/extractClient.get_extract_cooldown(ship_id: String) -> responses::CooldownResponse
POST
/my/ships/{shipSymbol}/extract ?survey{}=surveyClient.extract_resources(ship_id: String, survey: Option<Survey>) -> responses::ExtractResourcesResponse
POST
/my/ships/{shipSymbol}/dockClient.dock_ship(ship_id: String) -> responses::StatusResponse
POST
/my/ships/{shipSymbol}/orbitClient.orbit_ship(ship_id: String) -> responses::StatusResponse
POST
/my/ships/{shipSymbol}/deliverClient.deliver_goods(ship_id: String, contract_id: String, trade_symbol: String, units: u64) -> responses::DeliveryResponse
POST
/my/ships/{shipSymbol}/refuelClient.refuel_ship(ship_id: String) -> responses::RefuelResponse
POST
/my/ships/{shipSymbol}/scan mode=scan_modeClient.scan_ships(ship_id: String, mode: shared::ScanMode) -> responses::ScanResponse
POST
/my/ships/{shipSymbol}/jettison symbol=HEAVY_MACHINERY units=99999Client.jettison_cargo(ship_id: String, trade_symbol: String, units: u64) -> responses::TransactionResponse
POST
/my/ships/{shipSymbol}/sell symbol=HEAVY_MACHINERY units=99999Client.sell_cargo(ship_id: String, trade_symbol: String, units: u64) -> responses::TransactionResponse
POST
/my/ships/{shipSymbol}/purchase symbol=HEAVY_MACHINERY units=99999Client.buy_cargo(ship_id: String, trade_symbol: String, units: u64) -> responses::TransactionResponse
GET
/my/ships/{shipSymbol}/jumpClient.get_jump_cooldown(ship_id: String) -> responses::CooldownResponse
POST
/my/ships/{shipSymbol}/jump destination=X1-OEClient.jump(ship_id: String, destination: String) -> responses::JumpResponse
/navigate
will support modes/dock
will support modes/orbit
will support modes/systems/.../markets
may eventually have commoditiesGET
/my/account # not implementedGET
/my/ships/{shipSymbol}/scan # not implemented but should return cooldownPOST
/my/ships/{shipSymbol}/chart # appears to be incompleteagent/delete
comes online, each test should create its own agent and check several functions for its lifetime, allowing multiple threads to work simultaneously and ensuring state for state-dependent endpoints