Skip to main content

A Python client library for interacting with the Synmetrix API

Project description

Synmetrix Python Client

A Python client library for interacting with the Synmetrix API.

Key Components

  1. GraphQL Client

    • Fully typed async client for GraphQL operations
    • WebSocket subscription support
    • Automatic query generation
    • Error handling and response validation
  2. Authentication Client

    • JWT token management
    • User authentication flows
    • Session handling
    • Password management

Installation

Using pip

pip install synmetrix-python-client

Using poetry

poetry add synmetrix-python-client

Quick Start

import asyncio
from synmetrix_python_client.graphql_client import Client
from synmetrix_python_client.auth import AuthClient

# Decode JWT token to get user_id
access_token = "your_access_token"
jwt_payload = AuthClient.parse_access_token(access_token)
user_id = jwt_payload["user_id"]

# Initialize client
client = Client(
    url="https://app.synmetrix.org/v1/graphql",
    headers={"Authorization": f"Bearer {access_token}"},
)

async def get_current_user():
    # Query current user
    current_user = await client.current_user(id=user_id)
    print(f"User: {current_user.users_by_pk.display_name}")

    # Subscribe to user updates
    async for update in client.sub_current_user(id=user_id):
        print(f"Update received: {update.users_by_pk.display_name}")

# Run the example
asyncio.run(get_current_user())

Documentation

API Reference

The library provides comprehensive API documentation in the following formats:

Development

Prerequisites

  • Python 3.9+
  • Poetry (Python package manager)

Setting up the development environment

  1. Clone the repository:
git clone https://github.com/ifokeev/synmetrix-python-client.git
cd synmetrix-python-client
  1. Install dependencies:
poetry install
  1. Activate the virtual environment:
poetry shell

Running Tests

poetry run pytest

Generating Documentation

To regenerate the documentation:

./scripts/generate_graphql_api_docs.sh # GraphQL documentation
./scripts/generate_auth_api_docs.sh    # Auth documentation

Generating GraphQL Client

To generate the GraphQL client:

poetry run generate-client

Note: please check remote_schema_url and remote_schema_headers in pyproject.toml to ensure the correct schema is used.

Publishing to PyPI

  1. Test PyPI release:
./scripts/push_to_testpypi.sh YOUR_PYPI_TOKEN
  1. Production PyPI release:
./scripts/push_to_pypi.sh YOUR_PYPI_TOKEN

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please:

Examples

For complete working examples of client usage, check the use_cases/ directory in the repository.

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

synmetrix_python_client-0.1.5.tar.gz (49.6 kB view details)

Uploaded Source

Built Distribution

synmetrix_python_client-0.1.5-py3-none-any.whl (78.8 kB view details)

Uploaded Python 3

File details

Details for the file synmetrix_python_client-0.1.5.tar.gz.

File metadata

  • Download URL: synmetrix_python_client-0.1.5.tar.gz
  • Upload date:
  • Size: 49.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.13 Darwin/24.3.0

File hashes

Hashes for synmetrix_python_client-0.1.5.tar.gz
Algorithm Hash digest
SHA256 657c20dff85e805e21a44a246cd5ac31750547de3b22c2deae844fa888ea3093
MD5 4f0b79303cf8116f8b8caf36dcadf1db
BLAKE2b-256 a69c23a85a4ff048a736e9f1e08b5607901ec491f62acb35861630726ce38c1a

See more details on using hashes here.

File details

Details for the file synmetrix_python_client-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for synmetrix_python_client-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 97897ea4546f57966e1e1e5d46c8e0dc9be486fd9b5a077bc149b92b12e63193
MD5 1bbb2b23985688e0cb5f3908f9c01ca7
BLAKE2b-256 619d6c34f45e0a98c94499c1d632cb3368f37392583967db556e10a56166eeaa

See more details on using hashes here.

Supported by

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