GithubHelp home page GithubHelp logo

eniotnatavnac / xivapi-py Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xivapi/xivapi-py

0.0 0.0 0.0 86 KB

An asynchronous Python client for XIVAPI

Home Page: https://pypi.org/project/pyxivapi/

License: MIT License

Python 100.00%

xivapi-py's Introduction

pyxivapi

An asynchronous Python client for XIVAPI

Codacy Badge PyPI version Python 3.6

Requirements

python>=3.6.0
asyncio
aiohttp

Installation

pip install pyxivapi

Supported API end points

  • /character/search
  • /character/id
  • /freecompany/search
  • /freecompany/id
  • /linkshell/search
  • /linkshell/id
  • /pvpteam/search
  • /pvpteam/id
  • /index/search (e.g. recipe, item, action, pvpaction, mount, e.t.c.)
  • /index/id
  • /lore/search
  • /lodestone/worldstatus

Documentation

https://xivapi.com/docs/

Example

import asyncio
import logging

import aiohttp
import pyxivapi
from pyxivapi.models import Filter, Sort


async def fetch_example_results():
    client = pyxivapi.XIVAPIClient(api_key="your_key_here")

    # Search Lodestone for a character
    character = await client.character_search(
        world="odin", 
        forename="lethys", 
        surname="lightpaw"
    )

    # Get a character by Lodestone ID with extended data & include their Free Company information, if it has been synced.
    character = await client.character_by_id(
        lodestone_id=8255311, 
        extended=True,
        include_freecompany=True
    )

    # Search Lodestone for a free company
    freecompany = await client.freecompany_search(
        world="gilgamesh", 
        name="Elysium"
    )

    # Item search with paging
    item = await client.index_search(
        name="Eden",
        indexes=["Item"],
        columns=["ID", "Name"],
        filters=[
            Filter("LevelItem", "gt", 520)
        ],
        sort=Sort("LevelItem", False),
        page=0,
        per_page=10
    )

    # Fuzzy search XIVAPI game data for a recipe by name. Results will be in English.
    recipe = await client.index_search(
        name="Crimson Cider", 
        indexes=["Recipe"], 
        columns=["ID", "Name", "Icon", "ItemResult.Description"]
    )

    # Fuzzy search XIVAPI game data for a recipe by name. Results will be in French.
    recipe = await client.index_search(
        name="Cidre carmin", 
        indexes=["Recipe"], 
        columns=["ID", "Name", "Icon", "ItemResult.Description"], 
        language="fr"
    )

    # Get an item by its ID (Omega Rod) and return the data in German
    item = await client.index_by_id(
        index="Item", 
        content_id=23575, 
        columns=["ID", "Name", "Icon", "ItemUICategory.Name"], 
        language="de"
    )

    filters = [
        Filter("ClassJobLevel", "gte", 0)
    ]

    # Get non-npc actions matching a given term (Defiance)
    action = await client.index_search(
        name="Defiance", 
        indexes=["Action", "PvPAction", "CraftAction"], 
        columns=["ID", "Name", "Icon", "Description", "ClassJobCategory.Name", "ClassJobLevel", "ActionCategory.Name"], 
        filters=filters,
        string_algo="match"
    )

    # Search ingame data for matches against a given query. Includes item, minion, mount & achievement descriptions, quest dialog & more.
    lore = await client.lore_search(
        query="Shiva",
        language="fr"
    )

    # Search for an item using specific filters
    filters = [
        Filter("LevelItem", "gte", 100)
    ]

    sort = Sort("LevelItem", True)

    item = await client.index_search(
        name="Omega Rod", 
        indexes=["Item"], 
        columns=["ID", "Name", "Icon", "Description", "LevelItem"],
        filters=filters,
        sort=sort,
        language="de"
    )

    await client.session.close()


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO, format='%(message)s', datefmt='%H:%M')
    loop = asyncio.get_event_loop()
    loop.run_until_complete(fetch_example_results())

xivapi-py's People

Contributors

yandawl avatar realfriesi avatar curtiscook avatar packetdancer avatar computergeek125 avatar codacy-badger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.