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 == UNSTABLEish

  • 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.
  • TODO: I'll benefit from a quick discussion w/the Xcures tech team.

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
  • Activate the environment
conda activate XCAPI

Production // pip

Install ( >> not yet registered with pypi <<)

# 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 --repository rcrf upload 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.2.tar.gz (5.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: xcures_api-0.0.3.2.tar.gz
  • Upload date:
  • Size: 5.0 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.2.tar.gz
Algorithm Hash digest
SHA256 173a59e302f7e7e360d72c82412d52e8931e1de78644721c7d8c70872606511d
MD5 9e74c0297165b53ae3575d6e31209657
BLAKE2b-256 8d2f15176b49d81804307587a67c4e2fb412883f805797dd0814088a7165694e

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