Skip to main content

Declarative GraphQL query builder for the AniList API.

Project description

Anisearch

Declarative GraphQL query builder for the AniList API.

Installation

pip install Anisearch

# For async support
pip install Anisearch[async]

Quick Start

from Anisearch import Anilist

anilist = Anilist()

# Get anime by ID
result = anilist.media(id=13601, type="ANIME") \
    .id().title("romaji", "english").episodes().status() \
    .execute()
print(result)

Builder API

Every query starts from an Anilist instance. Call .media(), .character(), .staff(), or .studio() to get a builder, chain the fields you want, then .execute().

Media

result = anilist.media(search="Psycho-Pass", type="ANIME") \
    .id().title("romaji", "english").genres().episodes().status() \
    .execute()

Character

result = anilist.character(search="Saber") \
    .id().name().image() \
    .execute()

Staff

result = anilist.staff(id=113803) \
    .id().name().image() \
    .execute()

Studio

result = anilist.studio(search="J.C. Staff") \
    .id().name() \
    .execute()

Pagination

Wrap any query with .paginate() to get paginated results:

result = anilist.media(search="Sword", type="ANIME") \
    .id().title("romaji") \
    .paginate(page=1, per_page=10) \
    .execute()

Nested Fields

Some fields accept sub-field selections:

result = anilist.media(id=13601) \
    .title("romaji", "english", "native") \
    .cover_image("large", "medium") \
    .characters(sort="FAVOURITES_DESC", per_page=5)(lambda c: c.id().name().image()) \
    .execute()

Fragments

Reuse field selections across queries with Fragment:

from Anisearch import Fragment

basic_info = Fragment.media(lambda m: m.id().title("romaji", "english").genres())

result = anilist.media(id=13601).use(basic_info).episodes().execute()

Retry Configuration

Customize retry behavior with RetryStrategy:

from Anisearch import RetryStrategy

retry = RetryStrategy(
    max_retries=5,
    on_rate_limit="wait",       # "wait" or "raise"
    on_server_error="backoff",  # "backoff" or "raise"
    max_wait=60,
)
anilist = Anilist(retry=retry)

Raw Query

For queries the builder doesn't cover, use raw_query:

query = """
query ($id: Int) {
  Media(id: $id) {
    id
    title { romaji }
  }
}
"""
result = anilist.raw_query({"id": 13601}, query)

Async Usage

All builders support async execution (requires aiohttp):

import asyncio
from Anisearch import Anilist

async def main():
    anilist = Anilist()
    result = await anilist.media(id=13601) \
        .id().title("romaji") \
        .execute_async()
    print(result)

asyncio.run(main())

License

MIT

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

anisearch-3.0.0.tar.gz (42.2 kB view details)

Uploaded Source

Built Distribution

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

anisearch-3.0.0-py3-none-any.whl (35.7 kB view details)

Uploaded Python 3

File details

Details for the file anisearch-3.0.0.tar.gz.

File metadata

  • Download URL: anisearch-3.0.0.tar.gz
  • Upload date:
  • Size: 42.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for anisearch-3.0.0.tar.gz
Algorithm Hash digest
SHA256 4c3644b5dfbe838de0882a006c00e931cb98385cdd82d4885030f30ce17d3e73
MD5 e76e322eecd4c1aba24e1ed5994ad8b2
BLAKE2b-256 53b680a25141f97ebe0099df0b55c0e99fe04abc27fd6ba385614208c9932bde

See more details on using hashes here.

File details

Details for the file anisearch-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: anisearch-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for anisearch-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3457b99c6349fb4dd0cd39451c8fcc7f8f2646b254bb94bd3fc5884effd57e1a
MD5 7c71930426f4241197ed521974a998d6
BLAKE2b-256 094e8e8a12816d0b6cd02ad6fbcfe30dec4f0f4af2404619b6c2198bf5954b58

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