gandalf-python-sdk is a command-line tool designed to generate the necessary files that makes it super easy to interact with the Sauron API. It completely abstracts away the complexity of authentication and interacting with the GraphQL APIs.
- Generate necessary files required for interacting with the Sauron API
- Automatically install required dependencies
- Python - version 3.10 or higher
pip install git+https://github.com/gandalf-network/gandalf-sdk-python.git
eyeofsauron generate
- --folder [folder]: Set the destination folder for the generated files
Once you have successfully generated the necessary files and installed the required dependencies using eyeofsauron, you can proceed to use these files to interact with the API.
# Change eyeofsauron to suit the path you specified for the SDK generation
from eyeofsauron.client import Eye
from eyeofsauron.enums import Source
from eyeofsauron.enums import TraitLabel
eye = Eye("YOUR_PRIVATE_KEY")
import asyncio
async def main():
activities = await eye.get_activity(
data_key = 'YOUR_DATA_KEY',
source = Source.NETFLIX,
limit = 10,
page = 1,
)
print(activities)
"""
Returns
data = [
(
id='ACTIVITY_ID'
metadata=(
typename__='NetflixActivityMetadata',
subject=[
(
typename__='Identifier',
value='tt31473598',
identifier_type=<IdentifierType.IMDB: 'IMDB'>
),
(
typename__='Identifier',
value='10296096',
identifier_type=<IdentifierType.TVDB: 'TVDB'>
)
],
title="Judge Dee's Mystery: Season 1: Episode 3",
last_played_at='01/01/2024'
)
typename__='Activity'
), ...
]
limit=10
total=3409
page=1
typename__='ActivityResponse'
"""
asyncio.run(main())
activity = await eye.lookup_activity(
data_key="YOUR_DATA_KEY",
activity_id="ACTIVITY_ID"
)
print(activity)
"""
Returns
id='ACTIVITY_ID'
metadata=(
typename__='NetflixActivityMetadata',
subject=[
(
typename__='Identifier',
value='tt31473598',
identifier_type=<IdentifierType.IMDB: 'IMDB'>
),
(
typename__='Identifier',
value='10296096',
identifier_type=<IdentifierType.TVDB: 'TVDB'>
)
],
title="Judge Dee's Mystery: Season 1: Episode 3",
last_played_at='01/01/2024'
)
typename__='Activity'
"""
traits = await eye.get_traits(
data_key="YOUR_DATA_KEY",
source=Source.UBER,
labels=[TraitLabel.RATING, TraitLabel.TRIP_COUNT, TraitLabel.ACCOUNT_CREATED_ON],
)
print(traits)
"""
Returns
[
(
id='TRAIT_ID',
source=<Source.UBER: 'UBER'>,
label=<TraitLabel.RATING: 'RATING'>, value='5.0',
timestamp='2024-06-11T11:41:00.552647Z',
typename__='Trait',
),
(
id='TRAIT_ID_2',
source=<Source.UBER: 'UBER'>,
label=<TraitLabel.TRIP_COUNT: 'TRIP_COUNT'>, value='84',
timestamp='2024-06-11T11:41:00.552647Z',
typename__='Trait',
),
]
"""
trait = await eye.lookup_trait(
data_key="YOUR_DATA_KEY",
trait_id="TRAIT_ID"
)
print(trait)
"""
Returns
id='TRAIT_ID'
source=<Source.UBER: 'UBER'>
label=<TraitLabel.RATING: 'RATING'>
value='5.0'
timestamp='2024-06-11T11:41:00.552647Z'
typename__='Trait'
"""
When deploying your project that utilizes our CLI tool, it's essential to ensure that all necessary dependencies are included in your project's environment. Depending on your project setup, add these dependencies either through a requirements.txt file or using Poetry.
requirements.txt
ecdsa==0.19.0
httpx==0.27.0
pydantic==2.7.4
pydantic_core==2.18.4
requests==2.28.2
If you are managing your project with Poetry, execute the following command to add these dependencies to your pyproject.toml file:
poetry add ecdsa==0.19.0 httpx==0.27.0 pydantic==2.7.4 pydantic_core==2.18.4 requests==2.28.2
Contributions are welcome, whether they're feature requests, bug fixes, or documentation improvements.