Skip to main content

Async Python client for Stash GraphQL API

Project description

stash-graphql-client

PyPI version Python 3.12+ License: AGPL-3.0 codecov

Async Python client for Stash GraphQL API.

🔗 Quick Links

Features

  • ORM-like interface for GraphQL: Use .save(), .delete(), and relationship helpers instead of writing mutations manually.
  • Identity map with Pydantic v2 wrap validators: Same entity ID = same Python object reference. Nested objects with IDs are automatically separated into the identity map. Caching integrated at model construction—no separate cache layer needed.
  • Smart partial updates: UNSET sentinel marks fields have not been requested or received data from the server. Fields you change get sent in mutations. UNSET is also part of the three-state logic for knowing the difference between unknown and intentionally NULL.
  • Type-safe with Pydantic v2: Full runtime validation, IDE autocomplete, and error detection at development time.
  • Django-style filtering: Familiar rating100__gte=80 syntax instead of building complex GraphQL filter objects.
  • Lazy field population: populate() fetches only missing fields with nested __ syntax (files__path, studio__parent__name). filter_and_populate() and populated_filter_iter() combine filtering with auto-population.
  • Streaming iteration: find_iter() provides async generator pagination for large result sets without loading everything into memory.
  • Get-or-create: store.get_or_create() upsert pattern for entities.
  • Async-first architecture: Built for async/await throughout with native support for concurrent operations.
  • Full Stash API coverage: Complete CRUD operations for all entity types, job management, metadata operations, and real-time subscriptions.

Quick Example

import asyncio

from stash_graphql_client import StashContext
from stash_graphql_client.types import UNSET, Scene


async def main():
    context = StashContext(conn={"Host": "localhost", "Port": 9999})
    client = context.client

    # Find and update a scene
    scene = await client.find_scene("scene-id")
    scene.rating100 = 95
    # scene.details stays UNSET (no data loaded for it, won't be sent)
    await scene.save(client)  # Only sends rating100

    # Django-style filtering via the context's store
    store = context.store
    top_rated = await store.find(Scene, rating100__gte=90)


asyncio.run(main())

Learn More


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)


Connection Options

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

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-or-later).

See LICENSE for the full license text.

This license ensures:

  • ✅ Open source code sharing
  • ✅ Network use requires source disclosure
  • ✅ Compatible with Stash (also AGPL-3.0)
  • ✅ Derivative works must also be AGPL-3.0

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.12.5a0.tar.gz (230.6 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.12.5a0-py3-none-any.whl (277.4 kB view details)

Uploaded Python 3

File details

Details for the file stash_graphql_client-0.12.5a0.tar.gz.

File metadata

  • Download URL: stash_graphql_client-0.12.5a0.tar.gz
  • Upload date:
  • Size: 230.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stash_graphql_client-0.12.5a0.tar.gz
Algorithm Hash digest
SHA256 336ad96142b723dc131a44daa43ee22fe58abd749d34284a20f97f23da95d075
MD5 5ea0b6141dfb20d2c893c3692faa61fa
BLAKE2b-256 173ab93b90d6a2e8f07fbeba6c1abca2699d886c16732ecc762426dce9cc3c54

See more details on using hashes here.

Provenance

The following attestation bundles were made for stash_graphql_client-0.12.5a0.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.12.5a0-py3-none-any.whl.

File metadata

File hashes

Hashes for stash_graphql_client-0.12.5a0-py3-none-any.whl
Algorithm Hash digest
SHA256 40f421dfc9846191d26908e74f8006f923a283d595a16b106082f7af57d55384
MD5 61ba9d96ef05eb9e0269568265296158
BLAKE2b-256 d96508aed309daa65c57289e616dd25b9148066be91a4dd3e893cfc489fcfe79

See more details on using hashes here.

Provenance

The following attestation bundles were made for stash_graphql_client-0.12.5a0-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