Skip to main content

A client for the Pixel Starships Fleet Data API.

Project description

Pixel Starships Fleet Data API client

Support Discord server invite Development status Package version Supported Python versions Code coverage

An async client library to access the PSS Fleet Data API. Currently supported API version is 1.5.0.

Built with

✨ Features

  • Fully typehinted so your favorite IDE can assist you with code completion.
  • Easy access to any instance of a PSS Fleet Data API server.
  • Fast setup to get you started quickly.

🔍 Future plans

  • Support more Python versions

🚀 Demo

To retrieve the last month's tournament results (a specific Collection):

import asyncio
from datetime import datetime, timezone

from pss_fleet_data import ParameterInterval, PssFleetDataClient, utils

# Create the client, specifying the API server's base URL. If you don't specify a base URL, it defaults to https://fleetdata.dolores2.xyz
client = PssFleetDataClient(base_url="https://fleetdata.dolores2.xyz")

async def print_latest_tournament_results():
    # Get the current time
    now = datetime.now(tz=timezone.utc)

    # Tournament results are collected shortly before the start of a new month.
    # Calculate the most recent start of month relative to now.
    most_recent_timestamp = utils.get_most_recent_timestamp(now, ParameterInterval.MONTHLY)

    # Then get the most recent data collected before the calculated timestamp.
    collection = await client.get_most_recent_collection_by_timestamp(most_recent_timestamp)

    # Work with the Collection.
    print(f"Collection with ID {collection.metadata.collection_id} collected at {collection.metadata.timestamp}.")
    print(f"It has collected {collection.metadata.fleet_count} fleets and {len(collection.users)} players.")

    # You can use the Collection's ID in other methods, too, e.g. get the top 100 players at the end of the month.
    _, top_100_users = await client.get_top_100_users_from_collection(collection.metadata.collection_id)
    print(f"The player ranked 3rd last month was: {top_100_users[2].name}")

    # Or obtain the player stats of the 2nd best player last month over time
    user_history = await client.get_user_history(top_100_users[1].id, interval=ParameterInterval.MONTHLY)
    print(
        "Found %i history entries for player %s from %s to %s",
        len(user_history),
        top_100_users[1].name,
        user_history[0].collection.timestamp.isoformat(),
        user_history[-1].collection.timestamp.isoformat(),
    )

if __name__ == "__main__":
    asyncio.run(print_latest_tournament_results())

The library converts localized datetime objects to UTC or assumes UTC, if now timezone information is given. Any datetime objects returned are in UTC.

⚙️ Installation

Python 3.11 or higher is required

To install the latest version of this library, run the following command:

pip install -U pss-fleet-data-client

🖊️ Contribute

If you ran across a bug or have a feature request, please check if there's already an issue for that and if not, open a new one.

If you want to fix a bug or add a feature, please check out the Contribution Guide.

🆘 Support

If you need help using the library or want to contribute, you can join my support Discord at: discord.gg/kKguSec

🔗 Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pss_fleet_data_client-0.8.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pss_fleet_data_client-0.8.0-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file pss_fleet_data_client-0.8.0.tar.gz.

File metadata

  • Download URL: pss_fleet_data_client-0.8.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pss_fleet_data_client-0.8.0.tar.gz
Algorithm Hash digest
SHA256 4568754fac076e5b561ca1f9e3102de0080c1db19155c698e71d71af610378fa
MD5 95975c681dad81b0e3287e19f015011f
BLAKE2b-256 79bed0d44d6eeb9e6d59ea4caf29303868975cc7e7b4fe8afa6035d3a8fc7ce2

See more details on using hashes here.

File details

Details for the file pss_fleet_data_client-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: pss_fleet_data_client-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pss_fleet_data_client-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d69fc717a32d87b78e5bcec29eaa22d7572dc1d4abd8156d89483545bb1d7dbd
MD5 7b139b30ac382cba252294f1ad7a252c
BLAKE2b-256 a80ad418d705adbed999701b391c95fbf014b27fe4739872b50f01cb27a8fb33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page