API Documentation#
Subpackages#
Submodules#
autotraders.agent module#
- class autotraders.agent.Agent(session: AutoTradersSession, symbol=None, data: dict | None = None)#
Bases:
SpaceTradersEntity
- account_id: str#
- static all(session, page: int = 1) PaginatedList #
- contracts: PaginatedList | None#
- static create(session, faction, symbol, email, override_email_check=False)#
- credits: int#
- headquarters: WaypointSymbol#
- ship_count: int#
- ships: PaginatedList | None#
- starting_faction: str#
- symbol: str#
- update(data: dict | None = None)#
autotraders.error module#
- exception autotraders.error.SpaceTradersException(error, url, status_code, request_headers, response_headers)#
Bases:
Exception
autotraders.paginated_list module#
- class autotraders.paginated_list.PaginatedList(func, page, num_per_page=20)#
Bases:
object
- Variables:
page – The current page
num_per_page – The number of items per a page
total – Total number of items
pages – number of pages
- all()#
Gets all the pages and returns the list of all pages
- clear_cache()#
- current()#
- get()#
- next()#
- prev()#
- stitch()#
This method combines all elements in the inner data structure.
autotraders.session module#
autotraders.space_traders_entity module#
- class autotraders.space_traders_entity.SpaceTradersEntity(session: AutoTradersSession, action_url, data: dict | None = None)#
Bases:
object
- get(action: str | None = None) dict #
- patch(action: str, data=None) dict #
- post(action: str, data=None) dict #
- update(data: dict | None = None)#
- update_attr(mappings: dict[str, Any], data: dict[str, Any])#
autotraders.status module#
- class autotraders.status.Announcement(*, title: str, body: str)#
Bases:
BaseModel
- body: str#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'body': FieldInfo(annotation=str, required=True), 'title': FieldInfo(annotation=str, required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- title: str#
- class autotraders.status.Link(*, name: str, url: Url)#
Bases:
BaseModel
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'name': FieldInfo(annotation=str, required=True), 'url': FieldInfo(annotation=Url, required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- name: str#
- url: Url#
- class autotraders.status.ServerResets(*, next: AwareDatetime, frequency: str)#
Bases:
BaseModel
- frequency: str#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'frequency': FieldInfo(annotation=str, required=True), 'next': FieldInfo(annotation=AwareDatetime, required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- next: AwareDatetime#
- class autotraders.status.Status(*, status: str, version: str, resetDate: date, description: str, stats: dict[str, int], leaderboards: dict[str, list[dict[str, Any]]], serverResets: ServerResets, announcements: list[Announcement], links: list[Link])#
Bases:
BaseModel
- Variables:
status – User-Readable description of the server status
version – The server version
reset_date – A datetime of the last reset date
description – A user-readable description of the server
stats – A dictionary of stats. The keys are agents, ships, systems, and waypoints
leaderboards – The list of leaderboards (most credits, most charts)
announcements – A list of announcements
links – A list of useful links
server_resets – Info about the server resets
- announcements: list[Announcement]#
- description: str#
- leaderboards: dict[str, list[dict[str, Any]]]#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'announcements': FieldInfo(annotation=list[Announcement], required=True), 'description': FieldInfo(annotation=str, required=True), 'leaderboards': FieldInfo(annotation=dict[str, list[dict[str, Any]]], required=True), 'links': FieldInfo(annotation=list[Link], required=True), 'reset_date': FieldInfo(annotation=date, required=True, alias='resetDate', alias_priority=2), 'server_resets': FieldInfo(annotation=ServerResets, required=True, alias='serverResets', alias_priority=2), 'stats': FieldInfo(annotation=dict[str, Annotated[int, Gt]], required=True), 'status': FieldInfo(annotation=str, required=True), 'version': FieldInfo(annotation=str, required=True)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- reset_date: date#
- server_resets: ServerResets#
- stats: dict[str, int]#
- status: str#
- version: str#
autotraders.time module#
- autotraders.time.parse_time(time: str) datetime #
- Parameters:
time – A string representing a timestamp in either ISO format (YYYY-MM-DDTHH:MM:SS.SSSZ) or a custom format (%Y-%m-%dT%H:%M:%S.%fZ).
- Returns:
A datetime object with the parsed timestamp.
Note
Works with python 3.9+ and parses timezones.
autotraders.util module#
- autotraders.util.distance(*args)#
If there is one arg, then the arg should be a iterable of length 2 or 4. It will be expanded and used as a 2 or 4 arg. If there are 2 args, then they should both have x and y attributes if there are 4 args they should be in the format x_1, y_1, x_2, y_2
- Returns:
The euclidian distance between the two objects.
- autotraders.util.travel_fuel(distance, mode)#
- autotraders.util.travel_time(distance, ship_speed, mode)#
Module contents#
A spacetraders api
- autotraders.register_agent(symbol: str, faction: str, email=None, url='https://api.spacetraders.io/v2/')#