Skip to main content

Async Python client for XIVAPI for Final Fantasy XIV

Project description

xivapy

An async python client for accessing XIVAPI data for Final Fantasy XIV.

Features

  • Custom model support powered by pydantic
  • Async python
  • Type hints throughout for pleasant developer experience
  • All major endpoints of xivapi covered

Installation

pip install xivapy

Quick Start

The easiest way to use the client is to define a model and try looking through a sheet with a search.

import xivapy

class ContentFinderCondition(xivapy.Model):
    # Custom map a python field to an xivapi field name
    id: xivapy.QueryField[int] = xivapy.QueryField(FieldMapping('row_id'))
    # compress language fields into a dictionary for easy viewing
    # for this, however, you'll need to set up a default dict for it to use
    # The output of this is:
    # {
    #   'en': "The Protector and the Destroyer",
    #   'de': "Schützer des Volkes, Schlächter des Volkes",
    #   'fr': "Protecteurs et destructeurs",
    #   'ja': "護る者、壊す者"
    # }
    # Optional languages will be omitted
    name: xivapy.QueryField[xivapy.LangDict] = xivapy.QueryField(FieldMapping('Name', languages=['en', 'de', 'fr', 'ja']))
    # get a deeply nested (and optional) field lifted up into a top-level field
    bgm_file: xivapy.QueryField[str | None] = xivapy.QueryField(xivapy.FieldMapping('Content.BGM.File'))
    # by default, the sheet to be searched will be the name of the model
    # if you wish to override this, set the following:
    #__sheetname__ = 'SomeOtherSheetName'

async with xivapy.Client() as client:
    # Search ContentFinderCondition for all content that mentor roulette applies to
    async for content in client.search(ContentFinderCondition, query=xivapy.QueryBuilder().where(MentorRoulette=1)):
        # Data is typed as SearchResult[ContentFinderCondition], accessable by the `.data` field
        print(f'{content.data.name.get('en', 'No English Name')} ({content.data.id}) - {content.data.bgm_file}')

    # The same thing, but for a single id:
    result = await client.sheet(ContentFinderCondition, row=998)
    if result is not None:
        # result is a ContentFinderCondition instance
        print(result)
    # You can also search for multiple ids:
    async for result in client.sheet(ContentFinderCondition, rows=[1, 3, 99, 128]):
        # result is of type ContentFinderCondition
        print(result)

API Reference

You can see the docs at https://macrocosmos-app.github.io/xivapy

Development

The only real prerequisite you need is uv; afterwards:

  • git clone https://github.com/macrocosmos-app/xivapy
  • uv sync --locked

Afterwards, you should be able to develop against the library or use it with uv run python in a shell (for example) - it's an editable package inside the virtual environment.

Code quality

To ensure code quality, install the pre-commit hooks with:

uv run pre-commit install --install-hooks

This ensures that commits follow a baseline quality and typing standard. This project uses ruff for formatting and checking (see docs); configure your formatter or use uv run ruff format ... as appropriate for your environment.

For typing, this project uses mypy; you can check with uv run mypy for a basic check, though the pre-commit hooks have a few extra flags.

Testing and coverage

You can run the existing tests (and get coverage) with

uv run coverage run -m pytest
uv run coverage report

License

MIT License - see LICENSE file

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

xivapy-0.5.0.tar.gz (60.7 kB view details)

Uploaded Source

Built Distribution

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

xivapy-0.5.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file xivapy-0.5.0.tar.gz.

File metadata

  • Download URL: xivapy-0.5.0.tar.gz
  • Upload date:
  • Size: 60.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xivapy-0.5.0.tar.gz
Algorithm Hash digest
SHA256 efabf035cdbff64a186b01dfe38d830164b73c45be7602302354370afd8d880e
MD5 5d2ff511ea92d92723f7825c3f890ff7
BLAKE2b-256 6cf3fb2a04846206ac3642085667b68b888640c0217ef3ae49478e293cf5993f

See more details on using hashes here.

Provenance

The following attestation bundles were made for xivapy-0.5.0.tar.gz:

Publisher: publish.yml on macrocosmos-app/xivapy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xivapy-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: xivapy-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xivapy-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c406407f7cb48edeafe9fb1779cef1ff33c5cc5c21ce00e869c88ad1288b0d3
MD5 5794ad3b3f3d5000a7cb69f19cf31ace
BLAKE2b-256 d413a30d8e4a5afedd099a6e47fbf817535079f5eaae3254dbbc2c278a8afe9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for xivapy-0.5.0-py3-none-any.whl:

Publisher: publish.yml on macrocosmos-app/xivapy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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