Python SDK
The official Python SDK provides an async-first interface to the Pulls API with Pydantic models and type hints.
Installation (Coming Soon)
Section titled “Installation (Coming Soon)”pip install pulls-apiQuick Start (Preview)
Section titled “Quick Start (Preview)”import osfrom pulls import PullsAPI
pulls = PullsAPI(api_key=os.environ["PULLS_API_KEY"])
# Get a cardcard = pulls.cards.get("sv7-001")print(card.name) # "Bulbasaur"
# Search cardsresults = pulls.search.cards( query="Charizard", tcg="pokemon")
# List pricesprices = pulls.prices.list( card_ids=["sv7-001", "sv7-002"])Async Support (Preview)
Section titled “Async Support (Preview)”import asynciofrom pulls import AsyncPullsAPI
async def main(): pulls = AsyncPullsAPI(api_key=os.environ["PULLS_API_KEY"])
# Concurrent requests card, prices = await asyncio.gather( pulls.cards.get("sv7-001"), pulls.prices.list(card_ids=["sv7-001"]) )
print(f"{card.name}: ${prices[0].market}")
asyncio.run(main())Using OpenAPI Generator
Section titled “Using OpenAPI Generator”Until the official SDK is released, generate a client from our OpenAPI spec:
# Install OpenAPI Generatornpm install @openapitools/openapi-generator-cli -g
# Generate Python clientopenapi-generator-cli generate \ -i https://api.pulls.app/openapi.json \ -g python \ -o ./pulls-client
# Install generated clientpip install ./pulls-clientUsing httpx Directly
Section titled “Using httpx Directly”import httpximport os
API_KEY = os.environ["PULLS_API_KEY"]BASE_URL = "https://api.pulls.app/v1"
headers = {"Authorization": f"Bearer {API_KEY}"}
# Get a cardresponse = httpx.get(f"{BASE_URL}/cards/sv7-001", headers=headers)card = response.json()print(card["name"])
# Search cardsresponse = httpx.get( f"{BASE_URL}/search", params={"query": "Charizard", "tcg": "pokemon"}, headers=headers)results = response.json()Pydantic Models (Preview)
Section titled “Pydantic Models (Preview)”from pydantic import BaseModelfrom typing import Optionalfrom enum import Enum
class Tcg(str, Enum): POKEMON = "pokemon" MTG = "mtg" YUGIOH = "yugioh" LORCANA = "lorcana" ONEPIECE = "onepiece"
class CardSet(BaseModel): id: str name: str
class Prices(BaseModel): market: float low: float high: float
class Card(BaseModel): id: str name: str tcg: Tcg set: CardSet number: Optional[str] = None rarity: Optional[str] = None image_url: Optional[str] = None prices: Optional[Prices] = NoneNotify Me
Section titled “Notify Me”Want to be notified when the Python SDK launches?
Related
Section titled “Related”- TypeScript SDK (available now)
- API Reference
- OpenAPI Spec