semvec/pypi-packages huggingface dataset:
xivapi2 0.1.0b1
An unofficial asynchronous Python library for xivapi.
Requires Python: >=3.12

Overview
========

xivapi2 is an unofficial asynchronous Python library for `xivapi <https://v2.xivapi.com/>`__.

Installation
============

You can install this library using pip:

.. code:: shell

   pip install xivapi2

Usage
=====

Interacting with sheets
-----------------------

To get a list of sheets currently supported by xivapi, you can use the
``sheets`` method:

.. code:: python

    import asyncio
    from xivapi2 import XivApiClient

    async def main():
        client = XivApiClient()
        sheets = await client.sheets()
        for sheet in sheets:
            print(sheet)

    asyncio.run(main())


To list what rows a specific sheet has, you can use the
``sheet_rows`` method:

.. code:: python

    import asyncio
    from xivapi2 import XivApiClient

    async def main():
        client = XivApiClient()
        async for row in client.sheet_rows("Item", fields=["Name", "Description"], limit=40):
            print(f"ID: {row.row_id}, Name: {row.fields["Name"]}, Description: {row.fields["Description"]}")

    asyncio.run(main())

To get detailed information on a specific row, you can use the
``get_sheet_row`` method:

.. code:: python

    import asyncio
    from xivapi2 import XivApiClient

    async def main():
        client = XivApiClient()
        row = await client.get_sheet_row("Item", 12056)
        print(row.fields["Name"])
        print(row.fields["Description"])

    row = asyncio.run(main())


Searching
---------
To search for data in a specific sheet, you can use the ``search`` method.

First, construct a search query using the ``QueryBuilder`` class.

.. code:: python

    import asyncio
    from xivapi2 import XivApiClient, QueryBuilder, FilterGroup

    query = (
        QueryBuilder("Item")
        .add_fields("Name", "Description")
        .filter("IsUntradable", "=", False)
        .filter(
            FilterGroup()
            .filter("Name", "~", "Gemdraught")
            .filter("Name", "~", "Vitality", exclude=True)
        )
        .set_version(7.2)
        .limit(100)
    )

Then, pass the constructed query to the clients ``search`` method,

.. code:: python

    async def main(query):
        client = XivApiClient()
        async for result in client.search(query):
            print(result.fields["Name"])
            print(result.fields["Description"])

    asyncio.run(main(query))


For information on other available methods, please refer to the documentation page:
https://xivapi2.readthedocs.io/en/latest/
xivuniversalis 0.1.0b1
An unofficial asynchronous Python library for the Universalis API.
Requires Python: >=3.11

Overview
========

xivuniversalis is an unofficial asynchronous Python library for the `Universalis REST API <https://docs.universalis.app/>`__.

Important
=========
This library is still in development and is not guaranteed to be stable or feature-complete.

Installation
============
You can install this library using pip:

.. code:: shell

   pip install xivuniversalis

Usage
=====
A common use case for the Universalis API is looking up item listings. This can be done with the ``UniversalisClient.get_listings`` method,

.. code:: python

    import asyncio
    from xivuniversalis import UniversalisClient

    client = UniversalisClient()
    results = asyncio.run(client.get_listings(4, "crystal"))
    print(f"Found {len(results.active_listings)} listings")
    for listing in results.active_listings:
        print(f"[{listing.world_name}] {listing.quantity}x{listing.price_per_unit}/each ({listing.total_price} gil total)")

You must have the item ID's for the items you wish to look up.

If you need a source to obtain these from, you can use a service such as `xivapi <https://v2.xivapi.com/>`__.

You can also use the ``UniversalisClient.get_market_data`` method to find an item's cheapest listing, average price, and other useful metrics.

.. code:: python

    import asyncio
    from xivuniversalis import UniversalisClient

    client = UniversalisClient()
    market_data = asyncio.run(client.get_market_data(12056, "north-america"))
    print(f"[{market_data.nq.lowest_price.region_world_id}] Found listing for {market_data.nq.lowest_price.by_region} gil")
    print(f"Average listing price is {market_data.nq.average_price.by_region} gil")

You may have noticed above that we are referencing a world ID instead of a world name.

For endpoints where world names are not available, you can use the libraries ``UniversalisClient.get_worlds`` method to build a dictionary mapping that will allow you to easily convert world ID's back into human-readable world names.

.. code:: python

    import asyncio
    from xivuniversalis import UniversalisClient

    client = UniversalisClient()
    worlds = asyncio.run(client.get_worlds())
    world_id = 37
    print(worlds[world_id].name)

Links
=====
* `Documentation <https://xivuniversalis.readthedocs.io/en/latest/>`__