Skip to content

gandalf-network/gandalf-sdk-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gandalf-python-sdk

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.

Features

  • Generate necessary files required for interacting with the Sauron API
  • Automatically install required dependencies

Installation

Prerequisites

  • Python - version 3.10 or higher

Installing eyeofsauron

pip install git+https://github.com/gandalf-network/gandalf-sdk-python.git

Usage

eyeofsauron generate

Flags

  • --folder [folder]: Set the destination folder for the generated files

Using 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.

Initialization

# 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")

Get Activity

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())

Lookup Activity

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'
"""

Get Traits

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',
    ),
]
"""

Lookup 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'
"""

Deployment

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

requirements.txt

ecdsa==0.19.0
httpx==0.27.0
pydantic==2.7.4
pydantic_core==2.18.4
requests==2.28.2

poetry

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

Contributing

Contributions are welcome, whether they're feature requests, bug fixes, or documentation improvements.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages