Name | pss-fleet-data-client JSON |
Version |
0.7.0
JSON |
| download |
home_page | None |
Summary | A client for the Pixel Starships Fleet Data API. |
upload_time | 2024-10-26 11:27:19 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.11 |
license | MIT License Copyright (c) 2024 The worst. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
fleet data
pss
pixel starships
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
# Pixel Starships Fleet Data API client
<a href="https://discord.gg/kKguSec" target="_blank"><img src="https://discord.com/api/guilds/565819215731228672/embed.png" alt="Support Discord server invite"></a>
<a href="https://pypi.org/project/pss-fleet-data-client" target="_blank"><img src="https://img.shields.io/pypi/status/pss-fleet-data-client?color=%23DAB420&label=status" alt="Development status"></a>
<a href="https://pypi.org/project/pss-fleet-data-client" target="_blank"><img src="https://img.shields.io/pypi/v/pss-fleet-data-client?color=%23DAB420&label=pypi%20package" alt="Package version"></a>
<a href="https://pypi.org/project/pss-fleet-data-client" target="_blank"><img src="https://img.shields.io/pypi/pyversions/pss-fleet-data-client.svg?color=%23DAB420" alt="Supported Python versions"></a>
<img src="https://img.shields.io/codecov/c/github/pss-tools-development/pss-fleet-data-client" alt="Code coverage">
> An async client library to access the [PSS Fleet Data API](https://github.com/Zukunftsmusik/pss-fleet-data-api). Currently supported API version is **1.5.0**.
## Built with
- [httpx](https://www.python-httpx.org/)
- [pssapi.py](https://pypi.org/project/pssapi)
- [pydantic V2](https://docs.pydantic.dev/latest/)
# ✨ 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):
```python
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:
```sh
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](https://github.com/PSS-Tools-Development/pss-fleet-data-client/issues) for that and if not, [open a new one](https://github.com/PSS-Tools-Development/pss-fleet-data-client/issues/new).
If you want to fix a bug or add a feature, please check out the [Contribution Guide](CONTRIBUTING.md).
# 🆘 Support
If you need help using the library or want to contribute, you can join my support Discord at: [discord.gg/kKguSec](https://discord.gg/kKguSec)
# 🔗 Links
- Documentation (tbd)
- [Official Support Discord server](https://discord.gg/kKguSec)
- [PSS Fleet Data API](https://fleetdata.dolores2.xyz)
- [Buy me a can of cat food](https://buymeacoffee.com/the_worst_pss)
- [Or a coffee](https://ko-fi.com/theworstpss)
Raw data
{
"_id": null,
"home_page": null,
"name": "pss-fleet-data-client",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "Fleet Data, PSS, Pixel Starships",
"author": null,
"author_email": "\"The worst.\" <theworstpss@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a9/11/3e28420a73cab4ebda0b2bf44b2189fdbf596294d97f8b38732a9c278435/pss_fleet_data_client-0.7.0.tar.gz",
"platform": null,
"description": "# Pixel Starships Fleet Data API client\n\n<a href=\"https://discord.gg/kKguSec\" target=\"_blank\"><img src=\"https://discord.com/api/guilds/565819215731228672/embed.png\" alt=\"Support Discord server invite\"></a>\n<a href=\"https://pypi.org/project/pss-fleet-data-client\" target=\"_blank\"><img src=\"https://img.shields.io/pypi/status/pss-fleet-data-client?color=%23DAB420&label=status\" alt=\"Development status\"></a>\n<a href=\"https://pypi.org/project/pss-fleet-data-client\" target=\"_blank\"><img src=\"https://img.shields.io/pypi/v/pss-fleet-data-client?color=%23DAB420&label=pypi%20package\" alt=\"Package version\"></a>\n<a href=\"https://pypi.org/project/pss-fleet-data-client\" target=\"_blank\"><img src=\"https://img.shields.io/pypi/pyversions/pss-fleet-data-client.svg?color=%23DAB420\" alt=\"Supported Python versions\"></a>\n<img src=\"https://img.shields.io/codecov/c/github/pss-tools-development/pss-fleet-data-client\" alt=\"Code coverage\">\n\n> An async client library to access the [PSS Fleet Data API](https://github.com/Zukunftsmusik/pss-fleet-data-api). Currently supported API version is **1.5.0**.\n\n## Built with\n\n- [httpx](https://www.python-httpx.org/)\n- [pssapi.py](https://pypi.org/project/pssapi)\n- [pydantic V2](https://docs.pydantic.dev/latest/)\n\n# \u2728 Features\n\n- **Fully typehinted** so your favorite IDE can assist you with code completion.\n- **Easy access** to any instance of a **PSS Fleet Data API** server.\n- **Fast setup** to get you started quickly.\n\n# \ud83d\udd0d Future plans\n\n- Support more Python versions\n\n# \ud83d\ude80 Demo\nTo retrieve the last month's tournament results (a specific Collection):\n```python\nimport asyncio\nfrom datetime import datetime, timezone\n\nfrom pss_fleet_data import ParameterInterval, PssFleetDataClient, utils\n\n# 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\nclient = PssFleetDataClient(base_url=\"https://fleetdata.dolores2.xyz\")\n\nasync def print_latest_tournament_results():\n # Get the current time\n now = datetime.now(tz=timezone.utc)\n\n # Tournament results are collected shortly before the start of a new month.\n # Calculate the most recent start of month relative to now.\n most_recent_timestamp = utils.get_most_recent_timestamp(now, ParameterInterval.MONTHLY)\n\n # Then get the most recent data collected before the calculated timestamp.\n collection = await client.get_most_recent_collection_by_timestamp(most_recent_timestamp)\n\n # Work with the Collection.\n print(f\"Collection with ID {collection.metadata.collection_id} collected at {collection.metadata.timestamp}.\")\n print(f\"It has collected {collection.metadata.fleet_count} fleets and {len(collection.users)} players.\")\n\n # You can use the Collection's ID in other methods, too, e.g. get the top 100 players at the end of the month.\n _, top_100_users = await client.get_top_100_users_from_collection(collection.metadata.collection_id)\n print(f\"The player ranked 3rd last month was: {top_100_users[2].name}\")\n\n # Or obtain the player stats of the 2nd best player last month over time\n user_history = await client.get_user_history(top_100_users[1].id, interval=ParameterInterval.MONTHLY)\n print(\n \"Found %i history entries for player %s from %s to %s\",\n len(user_history),\n top_100_users[1].name,\n user_history[0].collection.timestamp.isoformat(),\n user_history[-1].collection.timestamp.isoformat(),\n )\n\nif __name__ == \"__main__\":\n asyncio.run(print_latest_tournament_results())\n```\nThe library converts localized `datetime` objects to UTC or assumes UTC, if now `timezone` information is given. Any `datetime` objects returned are in UTC.\n\n# \u2699\ufe0f Installation\n**Python 3.11 or higher is required**\n\nTo install the latest version of this library, run the following command:\n```sh\npip install -U pss-fleet-data-client\n```\n\n# \ud83d\udd8a\ufe0f Contribute\nIf you ran across a bug or have a feature request, please check if there's [already an issue](https://github.com/PSS-Tools-Development/pss-fleet-data-client/issues) for that and if not, [open a new one](https://github.com/PSS-Tools-Development/pss-fleet-data-client/issues/new).\n\nIf you want to fix a bug or add a feature, please check out the [Contribution Guide](CONTRIBUTING.md).\n\n# \ud83c\udd98 Support\nIf you need help using the library or want to contribute, you can join my support Discord at: [discord.gg/kKguSec](https://discord.gg/kKguSec)\n\n# \ud83d\udd17 Links\n- Documentation (tbd)\n- [Official Support Discord server](https://discord.gg/kKguSec)\n- [PSS Fleet Data API](https://fleetdata.dolores2.xyz)\n- [Buy me a can of cat food](https://buymeacoffee.com/the_worst_pss)\n- [Or a coffee](https://ko-fi.com/theworstpss)\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 The worst. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A client for the Pixel Starships Fleet Data API.",
"version": "0.7.0",
"project_urls": {
"Changelog": "https://github.com/PSS-Tools-Development/pss-fleet-data-client/releases",
"Issues": "https://github.com/PSS-Tools-Development/pss-fleet-data-client/issues",
"Repository": "https://github.com/PSS-Tools-Development/pss-fleet-data-client"
},
"split_keywords": [
"fleet data",
" pss",
" pixel starships"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7388994e91f0e75a64562cd4449b4e244891455110db025ee3d37b0e231d95f3",
"md5": "41a68388cca147388e29a086f27c6c7d",
"sha256": "e3c23f594c8c4ee666571ce6c044cce145f311eb323617fb8b52b07e3ca39e1f"
},
"downloads": -1,
"filename": "pss_fleet_data_client-0.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "41a68388cca147388e29a086f27c6c7d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 26196,
"upload_time": "2024-10-26T11:27:18",
"upload_time_iso_8601": "2024-10-26T11:27:18.341191Z",
"url": "https://files.pythonhosted.org/packages/73/88/994e91f0e75a64562cd4449b4e244891455110db025ee3d37b0e231d95f3/pss_fleet_data_client-0.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a9113e28420a73cab4ebda0b2bf44b2189fdbf596294d97f8b38732a9c278435",
"md5": "3f32e45d68f53e3fff83ac529de848fd",
"sha256": "a1e71eb7f57ec137fdc9d15a1e4612bd1e4a8f14045b6545d4495baa5313cff1"
},
"downloads": -1,
"filename": "pss_fleet_data_client-0.7.0.tar.gz",
"has_sig": false,
"md5_digest": "3f32e45d68f53e3fff83ac529de848fd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 21776,
"upload_time": "2024-10-26T11:27:19",
"upload_time_iso_8601": "2024-10-26T11:27:19.533339Z",
"url": "https://files.pythonhosted.org/packages/a9/11/3e28420a73cab4ebda0b2bf44b2189fdbf596294d97f8b38732a9c278435/pss_fleet_data_client-0.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-26 11:27:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PSS-Tools-Development",
"github_project": "pss-fleet-data-client",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "pss-fleet-data-client"
}