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
-
GraphQL Client
- Fully typed async client for GraphQL operations
- WebSocket subscription support
- Automatic query generation
- Error handling and response validation
-
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:
- HTML Documentation: Browse the full API reference at docs/src/synmetrix_python_client/
- GraphQL Client API: docs/src/synmetrix_python_client/graphql_client/client.html
- Authentication API: docs/src/synmetrix_python_client/auth.html
Development
Prerequisites
- Python 3.9+
- Poetry (Python package manager)
Setting up the development environment
- Clone the repository:
git clone https://github.com/ifokeev/synmetrix-python-client.git
cd synmetrix-python-client
- Install dependencies:
poetry install
- 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
Publishing to PyPI
- Test PyPI release:
./scripts/push_to_testpypi.sh YOUR_PYPI_TOKEN
- Production PyPI release:
./scripts/push_to_pypi.sh YOUR_PYPI_TOKEN
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, please:
- Open an issue in the GitHub repository
- Contact us at support@synmetrix.org
- Visit our documentation at https://docs.synmetrix.org
Examples
For complete working examples of client usage, check the use_cases/
directory in the repository.
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
Built Distribution
File details
Details for the file synmetrix_python_client-0.1.2.tar.gz
.
File metadata
- Download URL: synmetrix_python_client-0.1.2.tar.gz
- Upload date:
- Size: 49.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.13 Darwin/24.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8905d1e7aaeaa4dbd1de7b742d59af8f0fcf4f66ee88bc7aacd23313085c8fea |
|
MD5 | 27a55e33074f5517f307b24a5e521de5 |
|
BLAKE2b-256 | e28d47af2cf36e68cf65d1f6d4a3c9aaa3151e42e92e07ad9d451781231fd6f2 |
File details
Details for the file synmetrix_python_client-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: synmetrix_python_client-0.1.2-py3-none-any.whl
- Upload date:
- Size: 78.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.13 Darwin/24.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 584c391d1305d7fec9a565ebfbb496cd769ab673cc7ce9be5bcc23f12f984315 |
|
MD5 | b2972f91bf8b815f5f6acac469047f75 |
|
BLAKE2b-256 | 8a1824bc8701e4ade621d709f1413717e7df139bb707eedc28d436c35ebacdf6 |