brainstem-org / brainstem_python_api_tools

Python toolset for interacting with the REST API of BrainSTEM
1 stars 1 forks source link

create client #1

Closed luiztauffer closed 1 year ago

luiztauffer commented 1 year ago

This creates a client class for a better api experience.

Modification to be aware: I substituted the .mat for .json to store credentials locally. It helps getting rid of the unnecessary dependency of scipy. There’s no need to store the credentials in a local file though, since it will be stored in the client object, I kept the functionality just in case it is important for you guys

Example usage:

from client import StemClient
import os

# Setup client, user email and password will be requested if not present as ENV vars
username = os.environ.get("STEM_USERNAME")
password = os.environ.get("STEM_PASSWORD")

client = StemClient(
    username=username,
    password=password,
)

# Get dataset info
r = client.load_datasets(id='5867209b-c483-4a08-9135-d6b6aadf075e')
RoyVII commented 1 year ago

Hi Luiz,

Thank you very much for your contributions, we really like the client class approach for the API. I'm merging the PR into a development branch so I can also work over this.

Thank you!