Skip to main content

Async Python client for Stash GraphQL API

Reason this release was yanked:

Removing betas for versions with public releases

Project description

stash-graphql-client

PyPI version Python 3.12+ License: AGPL-3.0 codecov

Async Python client for Stash GraphQL API.

Features

  • Async-first: Built with gql + HTTPXAsyncTransport + WebsocketsTransport
  • Pydantic types: All Stash GraphQL schema objects as Pydantic models
  • Full CRUD: Operations for all entity types (Scene, Gallery, Performer, Studio, Tag, etc.)
  • Job management: Metadata scanning, generation, and job status tracking
  • Subscriptions: GraphQL subscription support for real-time updates

Installation

From PyPI (Recommended)

pip install stash-graphql-client

With Poetry

poetry add stash-graphql-client

From Source

git clone https://github.com/Jakan-Kink/stash-graphql-client.git
cd stash-graphql-client
poetry install

Requirements

  • Python 3.12+
  • Poetry for development

Quick Start

from stash_graphql_client import StashClient, StashContext

# Using context manager (recommended)
async with StashContext(conn={
    "Host": "localhost",
    "Port": 9999,
    "ApiKey": "your-api-key",  # Optional
}) as client:
    # Find all studios
    result = await client.find_studios()
    print(f"Found {result.count} studios")

    # Create a new tag
    tag = await client.create_tag(name="My Tag")
    print(f"Created tag: {tag.name}")

# Or manual lifecycle management
context = StashContext(conn={"Host": "localhost", "Port": 9999})
client = await context.get_client()
try:
    scenes = await client.find_scenes()
finally:
    await context.close()

Connection Options

conn = {
    "Scheme": "http",      # or "https"
    "Host": "localhost",   # Stash server host
    "Port": 9999,          # Stash server port
    "ApiKey": "...",       # Optional API key
}

Available Operations

Scenes

  • find_scenes(), find_scene(id), create_scene(), update_scene(), destroy_scene()

Galleries

  • find_galleries(), find_gallery(id), create_gallery(), update_gallery(), destroy_gallery()

Performers

  • find_performers(), find_performer(id), create_performer(), update_performer(), destroy_performer()

Studios

  • find_studios(), find_studio(id), create_studio(), update_studio(), destroy_studio()

Tags

  • find_tags(), find_tag(id), create_tag(), update_tag(), destroy_tag()

Metadata Operations

  • metadata_scan() - Scan for new media
  • metadata_generate() - Generate thumbnails, previews, etc.
  • find_job(), wait_for_job() - Job status tracking

Fuzzy Date Support (Stash v0.30.0+)

Stash v0.30.0 introduced support for partial dates (year-only or year-month formats) in addition to full dates. This client includes utilities to work with these "fuzzy" dates:

from stash_graphql_client.types import (
    FuzzyDate,
    validate_fuzzy_date,
    normalize_date,
    DatePrecision,
)

# Validate date formats
validate_fuzzy_date("2024")        # True - year only
validate_fuzzy_date("2024-03")     # True - year and month
validate_fuzzy_date("2024-03-15")  # True - full date
validate_fuzzy_date("2024-3")      # False - invalid format

# Create fuzzy dates
date = FuzzyDate("2024-03")
print(date.precision)  # DatePrecision.MONTH
print(date.to_datetime())  # datetime(2024, 3, 1)

# Normalize dates to different precisions
normalize_date("2024-03-15", "year")   # "2024"
normalize_date("2024-03-15", "month")  # "2024-03"
normalize_date("2024", "day")          # "2024-01-01"

# Use in performer/scene data
performer_data = {
    "name": "John Doe",
    "birthdate": "1990",  # Year-only birthdate
}
await client.create_performer(**performer_data)

scene_data = {
    "date": "2024-03",  # Month precision
}

Supported date formats:

  • YYYY - Year precision (e.g., "2024")
  • YYYY-MM - Month precision (e.g., "2024-03")
  • YYYY-MM-DD - Day precision (e.g., "2024-03-15")

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stash_graphql_client-0.5.0b2.tar.gz (177.1 kB view details)

Uploaded Source

Built Distribution

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

stash_graphql_client-0.5.0b2-py3-none-any.whl (220.8 kB view details)

Uploaded Python 3

File details

Details for the file stash_graphql_client-0.5.0b2.tar.gz.

File metadata

  • Download URL: stash_graphql_client-0.5.0b2.tar.gz
  • Upload date:
  • Size: 177.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stash_graphql_client-0.5.0b2.tar.gz
Algorithm Hash digest
SHA256 4552e31f2e44c9610d298d6469a1ae1cc7f04748c40f10324744523386084b94
MD5 a6ea657bf9833c88581038f55bef3b38
BLAKE2b-256 b0ea19d353e9db6ea9fb95802b06c629eca216094fa5f5bc6a1a87b84e49b50a

See more details on using hashes here.

Provenance

The following attestation bundles were made for stash_graphql_client-0.5.0b2.tar.gz:

Publisher: publish.yml on Jakan-Kink/stash-graphql-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stash_graphql_client-0.5.0b2-py3-none-any.whl.

File metadata

File hashes

Hashes for stash_graphql_client-0.5.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 427f94f47d2f89533ca9e82525d0159984529a187b298eb8889906e1827529da
MD5 2dd1acd8d5bbdaf9af761faba16dccca
BLAKE2b-256 766ce621f3a20630f7de27e49edbdb91a1f886a8704268976bafc24ac135c44c

See more details on using hashes here.

Provenance

The following attestation bundles were made for stash_graphql_client-0.5.0b2-py3-none-any.whl:

Publisher: publish.yml on Jakan-Kink/stash-graphql-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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