dragon-bot/ffxiv.py

104 lines
3.2 KiB
Python

import asyncio
import logging
import json
import pprint
import aiohttp
import xivapi
pp = pprint.PrettyPrinter(indent=4)
async def fetch_example_results(session):
client = xivapi.Client(session=session, api_key="189ab21cd81c4516b768aad19be1d0a92cf463254550463f982ac4172f138f67")
# Search Lodestone for a character
character = await client.character_search(
world="Exodus",
forename="Pizza",
surname="Rolls"
)
# Get a character by Lodestone ID with extended data & include their Free Company information, if it has been synced.
character2 = await client.character_by_id(
lodestone_id=character['Results'][0]['ID'],
extended=True,
include_freecompany=True
)
pp.pprint(json.dumps(character2))
# # Search Lodestone for a free company
# freecompany = await client.freecompany_search(
# world="gilgamesh",
# name="Elysium"
# )
# # 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"],
# string_algo="fuzzy"
# )
# # 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"],
# string_algo="fuzzy",
# 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"
# )
# # 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=["ClassJobLevel>=0", "ClassJobCategory.ID>0"],
# string_algo="fuzzy"
# )
# # 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("Name", True)
# item = await client.index_search(
# name="Omega Rod",
# indexes=["Item"],
# columns=["ID", "Name", "Icon", "Description", "LevelItem"],
# filters=filters,
# sort=sort,
# language="de"
# )
# Get all categories of posts from the Lodestone (cached evert 15 minutes)
lodestone = await client.lodestone_all()
await session.close()
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, format='%(message)s', datefmt='%H:%M')
loop = asyncio.get_event_loop()
session = aiohttp.ClientSession(loop=loop)
loop.run_until_complete(fetch_example_results(session))