A bare-bones wrapper package to utilitize Universalis API in python.
Project description
Universalis API wrapper
A simple and light weight wrapper for Universalis marketboard information.
Key Features
- Pythonic API wrapper using
asyncandawaitfunctionality. - Support for bulk item searching.
- JSON Responses are converted into useful classes.
- Listings and History are sorted by
timestamp.
- Listings and History are sorted by
- The ability to search by Final Fantasy 14 DataCenters or World.
Currently Supported Endpoints
- https://docs.universalis.app/#market-board-current-data
UniversalisAPI.get_current_data()andUniversalisAPI.get_bulk_current_data()
- https://docs.universalis.app/#market-board-sale-history
UniversalisAPI.get_history_data()andUniversalisAPI.get_bulk_history_data()
Example
A basic example of usage.
- We are looking up a single item (Fire Cluster[14]) for the Final Fantasy 14 World Zalera,
import aiohttp
from universalis import UniversalisAPI, World
async def sample() -> None:
item_id = 14 # Fire Cluster
# You only need to pass in a aiohttp.ClientSession if
# you already have one you are using elsewhere in your code base or have a Pool/etc..
session = aiohttp.ClientSession()
market = UniversalisAPI(session=session)
# You are able to limit the number of listings and history results by setting
# "num_history" or "num_listing".
entries = 50
# You can filter the data prior by only getting a specific Final Fantasy 14 World
# By default it will search an entire Datacenter which can be accessed via `<UniversalisAPI>.default_datacenter`
# Or you can pass a WorldEnum object as the `world_or_dc` parameter.
world = World.Zalera
cur_data: CurrentData = await market.get_current_data(
item=item_id,
num_history_entries=entries,
num_listings=entries,
world_or_dc=world,
)
# Maybe you want the single cheapest listing, simple call `sort_listings` and get the first entry.
sorted_list: list[CurrentDataEntries] = sorted(cur_data)
cheapest: CurrentDataEntries = sorted_list[0]
# Then the most expensive listing would be at the end.
# Example: expensive: CurrentDataEntries = sorted_list[-1]
# CurrentDataEntries has a pre-defined `__repr__()` and `__str__()`` to return useful attributes if desired.
print(cheapest.world_name, cheapest.price_per_unit, cheapest.quantity)
# or
# print(cheapest)
# You can also get the most expensive entry by setting
# the reverse parameter to "True". Thus flipping the order of the listings.
sorted_list = sorted(cur_data, reverse=True)
expensive: CurrentDataEntries = sorted_list[0]
print(expensive)
# This example shows using it as a context manager.
async def sample_two() -> None:
item_id = 14 # Fire Cluster
async with UniversalisAPI() as market:
# By default any searches will use `Datacenter.Crystal`
res: CurrentData = await market.get_current_data(item=item_id)
print(sorted(res.listings))
Additional Information
See Universalis docs for more information.
Need Help? -> Feel free to create an Issue~
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
File details
Details for the file async_universalis-6.0.0.dev0.tar.gz.
File metadata
- Download URL: async_universalis-6.0.0.dev0.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff0850102808d131499afdaf33d0a975ae09316c72bebe124399e2dbacf8b806
|
|
| MD5 |
03af53f4b181f9e6860f49b1925488b9
|
|
| BLAKE2b-256 |
70ecad40b19d0c16c56ea933c7985c7dd9ed3d06aea32a661ade81c1783ca9dc
|
Provenance
The following attestation bundles were made for async_universalis-6.0.0.dev0.tar.gz:
Publisher:
build.yml on k8thekat/UniversalisAPI_wrapper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
async_universalis-6.0.0.dev0.tar.gz -
Subject digest:
ff0850102808d131499afdaf33d0a975ae09316c72bebe124399e2dbacf8b806 - Sigstore transparency entry: 953239010
- Sigstore integration time:
-
Permalink:
k8thekat/UniversalisAPI_wrapper@4f3f4f49c9c2004197a0ce8db64989ab3483771f -
Branch / Tag:
refs/tags/v6.0.0-dev - Owner: https://github.com/k8thekat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@4f3f4f49c9c2004197a0ce8db64989ab3483771f -
Trigger Event:
release
-
Statement type: