Software SDKs Client SDK Client SDK: Usage Study Usage instructions for the Client SDK for Study
Quickstart
To write a report for a study with accession number $ACCESSION_NUMBER
with username $USERNAME
and private key filename $PRIVATE_KEY_FILENAME
, run:
🐍 Python 🟦 TS/JS
Copy from client_sdk import StudyAPIClient
async with StudyAPIClient (
username = "$USERNAME" ,
private_key_filename = "$PRIVATE_KEY_FILENAME" ,
) as client :
await client . set_report (
accession_number = "$ACCESSION_NUMBER" ,
report = "$REPORT" ,
)
Copy import { StudyAPIClient } from 'bunkerhill-inference-api/client' ;
const client = new StudyAPIClient ( '$USERNAME' , '$PRIVATE_KEY_FILENAME' );
await client .setReport (
'$ACCESSION_NUMBER' ,
'$REPORT' ,
);
StudyAPIClient
Reference
🐍 Python 🟦 TS/JS
Constructor
Method signature
Copy def __init__ (
self ,
username : str ,
private_key_filename : Optional [ str ] = None ,
private_key_string : Optional [ str ] = None ,
base_url : str = 'https://api.bunkerhillhealth.com/' ,
) -> None :
...
Parameters
username
(str
): The username to authenticate the client.
private_key_filename
(Optional[str]
): Filename of the RSA private key.
private_key_string
(Optional[str]
): The RSA private key as a string.
base_url
(str
, has a default): The base URL of the Inference API. Defaults to 'https://api.bunkerhillhealth.com/'.
Notes
At least one of private_key_filename
or private_key_string
must be provided.
set_report
Sets a report for a Study
object with a given accession number from the Study API. Must be called from an async context.
Hint: The set_report
method is asynchronous. To make use of this method from a synchronous application, calls to the StudyAPIClient
can be wrapped in asyncio.run()
.
Method signature
Copy def set_report (
self ,
accession_number : str ,
report : str ,
) -> None :
...
Parameters
accession_number
(str
): The accession number of the study.
report
(str
): The text of the report.
Returns
None
Notes
You must have authorization to the specified accession_number
. If not, a 403
error will be raised.
Only studies corresponding to institutions that you are authorized to will be writable.
Constructor
Method signature
Copy constructor (
username: string ,
privateKeyFilename ?: string ,
privateKeyString ?: string ,
baseUrl: string = 'https://api.bunkerhillhealth.com/' ,
) {}
Parameters
username
(string
): The username to authenticate the client.
privateKeyFilename
(string
, optional): Filename of the RSA private key.
privateKeyString
(string
, optional): The RSA private key as a string.
baseUrl
(string
, has a default): The base URL of the Inference API. Defaults to 'https://api.bunkerhillhealth.com/'.
Notes
At least one of privateKeyFilename
or privateKeyString
must be provided.
setReport
Sets a report for a Study
object with a given accession number from the Study API. Must be called from an async context.
Method signature
Copy async getInferences (
accessionNumber: string ,
report: string ,
): Promise <void> {}
Parameters
accessionNumber
(str
): The accession number of the study.
report
(str
): The text of the report.
Returns
Promise<void>
Notes
You must have authorization to the specified accessionNumber
. If not, a 403
error will be raised.
Only studies corresponding to institutions that you are authorized to will be accessible.