Skip to main content

Python wrapper for the xcures REST api, found here https://partner.xcures.com/api-docs.

Project description

xcures_api ( only necessary api calls being implemented ATM)

python wrapper for the xcures REST API.

Status

  • The auth functionality is working.
  • Subject API query is working, but not tested extensively.
  • Other API hooks, ie: query, are not implemented in a trusted way quite yet.

Installation

Development

Environment

Conda

conda create -y -n XCAPI -c conda-forge python=3.10 ipython pytest pip pytz requests ipython && conda activate XCAPI && pip install yaml_config_day twine black
  • Activate the environment
conda activate XCAPI

Production // pip

Install w/pip

pip install xcures_api

Configuration

YAML Credentials File

  • Based on credentials obtained from xcures. Using the yaml_config_day package.
  • Located in ~/.config/xcures/xcures_$XCURES_ENV.yaml, where XCURES_ENV= might be prod or test.
  • Contents:
export XCURES_ENV=prod
more ~/.config/xcures/xcures_$XCURES_ENV.yaml
---
base_url: "https://partner.xcures.com"
base_auth_url: "https://xcures-patient-registry-prod.us.auth0.com"
project_id: "PROJECTIDHERE"
client_id: "CLIENTIDHERE"
client_secret: "SECRETKEYHERE"

Usage

given the env is set and the yaml file is configured

Authenticate

from xcures.xcures_api import XCuresAPI as xc_api

# Initialize the API connection, using your credentials yaml file.
xc = xc_api()

# print the session id
print(xc)

# print your auth token
print(xc.token)

# print all subjects in the project
xc.subject()

Tests

Crude Dev Test

conda activate XCAPI
python xcures_api/xcures_api.py # just for quick dev, this will be moved to proper pytest.

Pytest

conda activate XCAPI
pytest
  • This is one test checking if failure to find an appropriate yaml file will raise an exception. I'm not certain how much effort to put into mocking the REST api behavior given credentials are needed to use it. TODO: check with the xcures dev team to see if there are test credentials available.

Update pypi

python setup.py sdist
twine upload --repository rcrf  dist/*

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

xcures_api-0.0.3.5.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file xcures_api-0.0.3.5.tar.gz.

File metadata

  • Download URL: xcures_api-0.0.3.5.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.14

File hashes

Hashes for xcures_api-0.0.3.5.tar.gz
Algorithm Hash digest
SHA256 078dec4fe580117ad139bc1e5b2d8206d02a3774b6bb6655258c0eb0bbc4c374
MD5 a8a161a310a5149cb9bd9691d408ebe2
BLAKE2b-256 4eaee9db4babdee382b65b5a022cbbc68d899a90517bb94472314646062ba974

See more details on using hashes here.

Supported by

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