Skip to main content

Asynchronous Python client for the Scryfall API

Project description

This is an early work in progress. I am currently in the phase of getting all of the features in place. Once everything is in place, I will clean up the API and add some abstraction layers and documentation on top.

For now, the API is very low level and you will need to read the Scryfall API and the code to figure out how to use it.

You will need Python >= 3.11 (I may change this to support earlier versions in the future) and you will need to use aiohttp.

A minimal use case to get yourself started:

import asyncio
import aiohttp
from aioscryfall.api.cards import UniqueMode
from aioscryfall.client import ScryfallClient

async def get_bolt():
    async with aiohttp.ClientSession() as session:
        client = ScryfallClient(session)
        bolts = [c async for c in client.cards.search("lightning bolt", unique=UniqueMode.PRINTS)]
        return bolts

bolts = asyncio.run(get_bolt())
print(len(bolts), bolts[0])

Or if you prefer not to use async:

from aioscryfall.api.cards import UniqueMode
from aioscryfall.sync.client import ScryfallSyncClient

client = ScryfallSyncClient()
bolts = list(client.cards.search("lightning bolt", unique=UniqueMode.PRINTS))
print(len(bolts), bolts[0])

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

aioscryfall-0.4.1.tar.gz (307.8 kB view hashes)

Uploaded Source

Built Distribution

aioscryfall-0.4.1-py3-none-any.whl (33.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page