Skip to main content

A bare-bones wrapper package to utilitize Universalis API in python.

Reason this release was yanked:

Failure to build

Project description

Universalis API wrapper

A simple and light weight wrapper for Universalis marketboard information.

Key Features

  • Pythonic API wrapper using async and await functionality.
  • Support for bulk item searching.
  • JSON Responses are converted into useful classes.
    • Listings and History are sorted by timestamp.
  • The ability to search by Final Fantasy 14 DataCenters or World.

Currently Supported Endpoints

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~

Discord Server

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

async_universalis-3.0.1.dev0.tar.gz (54.4 kB view details)

Uploaded Source

Built Distribution

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

async_universalis-3.0.1.dev0-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

Details for the file async_universalis-3.0.1.dev0.tar.gz.

File metadata

File hashes

Hashes for async_universalis-3.0.1.dev0.tar.gz
Algorithm Hash digest
SHA256 807fd75ecb318a4e1a0232191a31804c900b10320104ebd5b1531dd67100e852
MD5 79dd4c13aeb3b61072f394700b854590
BLAKE2b-256 b116de3ad6a97a14b1be23e62a63c0b2f0f519086788e7174974fe01a25ec428

See more details on using hashes here.

File details

Details for the file async_universalis-3.0.1.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for async_universalis-3.0.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cbb8046260e06964aab056f82af063d6cf324a168532ba864b8e134dd367c19
MD5 5db4d7e3c9a3fc39c9e8c1fb4f666a14
BLAKE2b-256 8efa30d425a3be8392510b1909cd1a04a74b6e3119a5e3fe34d23955ed986e12

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