# Slide Score Python SDK
This SDK contains the client library for using API of [Slide Score](https://www.SlideScore.com)
See the [documentation](https://www.slidescore.com/docs/api/index.html) for more
# Examples
For more examples see the examples folder
## Basic usage
- Import the module
- setup token
- setup URL of the Slide Score server
- create an instance of the API Client
from slidescore import *
token="eyJ....<your token>...."
url="https://slidescore.example.com/"
client = APIClient(url, token)
## Downloading a slide
Downloads a slide to the current directory ("."). Check the URL of the slide for image ID and study ID, or click Export cases button on study overview to get a list of slide IDs.
studyid=1
imageid=2
client.download_slide(studyid, imageid, ".")
## Uploading and adding a slide to a study
localFilePath="C:/file_to_upload.tiff"
uploadFolder="UploadTest"
serverFileName="renamedSlide.tiff"
client.upload_file(localFilePath, uploadFolder, serverFileName)
client.add_slide(studyid, uploadFolder+"/"+serverFileName)
## Upload answers - study results
Results are uploaded in the same format as the download.
resultsFilePath="c:/Users/User/Downloads/Study_23_06_21_11.txt"
with open(resultsFilePath, "r") as f:
res = f.read()
client.upload_results(studyid, res)
## Set slide description
You can use (limited) set of HTML tags in slide, case, study and module descriptions:
client.update_slide_description(studyid, imageid, 'Carina Nebula: Cosmic Cliffs, Glittering Landscape of Star Birth. Image Credit: NASA, ESA, CSA, and STScI <a href="https://esawebb.org/news/weic2205/">Original</a>');
## Make a request directly
The SDK doesn't include methods for all possible calls, sometimes you need to make the API request yourself:
response=clientlocal.perform_request("UpdateSlideName", {"imageId":imageid, "newName":'renamedSlide'}, method="POST")
rjson = response.json()
if 'success' not in rjson or rjson['success'] != True:
raise SlideScoreErrorException("Failed updating slide name: " + response.text);
Raw data
{
"_id": null,
"home_page": "https://github.com/SlideScore/SlideScore-python-sdk",
"name": "slidescore-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "slidescore, slide score, sdk, api",
"author": "Slide Score B.V.",
"author_email": "info@slidescore.com",
"download_url": "https://files.pythonhosted.org/packages/3c/a0/15f4bbb8934a4b1408b1d05ee32b6d5c7340f5059a8c746114b3b7d32054/slidescore-sdk-1.4.5.tar.gz",
"platform": null,
"description": "# Slide Score Python SDK\n\nThis SDK contains the client library for using API of [Slide Score](https://www.SlideScore.com)\t\nSee the [documentation](https://www.slidescore.com/docs/api/index.html) for more \n\n# Examples\n\nFor more examples see the examples folder\n\n## Basic usage\n\n- Import the module\n- setup token\n- setup URL of the Slide Score server\n- create an instance of the API Client\n\n from slidescore import *\n\n\n token=\"eyJ....<your token>....\"\n url=\"https://slidescore.example.com/\"\n\n client = APIClient(url, token)\n \n## Downloading a slide \n\nDownloads a slide to the current directory (\".\"). Check the URL of the slide for image ID and study ID, or click Export cases button on study overview to get a list of slide IDs.\n\n studyid=1\n imageid=2\n\n client.download_slide(studyid, imageid, \".\")\n\n\n## Uploading and adding a slide to a study\n\n localFilePath=\"C:/file_to_upload.tiff\"\n uploadFolder=\"UploadTest\"\n serverFileName=\"renamedSlide.tiff\"\n\n client.upload_file(localFilePath, uploadFolder, serverFileName)\n client.add_slide(studyid, uploadFolder+\"/\"+serverFileName) \n \n## Upload answers - study results\n\nResults are uploaded in the same format as the download.\n\n resultsFilePath=\"c:/Users/User/Downloads/Study_23_06_21_11.txt\"\n with open(resultsFilePath, \"r\") as f:\n res = f.read()\n client.upload_results(studyid, res)\n\n\n## Set slide description\n\nYou can use (limited) set of HTML tags in slide, case, study and module descriptions:\n\n client.update_slide_description(studyid, imageid, 'Carina Nebula: Cosmic Cliffs, Glittering Landscape of Star Birth. Image Credit: NASA, ESA, CSA, and STScI <a href=\"https://esawebb.org/news/weic2205/\">Original</a>');\n\n\n## Make a request directly\n\nThe SDK doesn't include methods for all possible calls, sometimes you need to make the API request yourself:\n\n response=clientlocal.perform_request(\"UpdateSlideName\", {\"imageId\":imageid, \"newName\":'renamedSlide'}, method=\"POST\")\n rjson = response.json()\n if 'success' not in rjson or rjson['success'] != True:\n raise SlideScoreErrorException(\"Failed updating slide name: \" + response.text);\n\n\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "SDK for using the API of Slide Score",
"version": "1.4.5",
"project_urls": {
"Homepage": "https://github.com/SlideScore/SlideScore-python-sdk"
},
"split_keywords": [
"slidescore",
" slide score",
" sdk",
" api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ce69530dc28aead7c54223ec639514d32f93c11b22696b0c9763bbab53f92cf7",
"md5": "8f5fecc72637ffba9c6f5c165830a188",
"sha256": "ed12def8e31bd87263a50f19df41ba7ed2e8e0f585ce18610a4cf58d8a958976"
},
"downloads": -1,
"filename": "slidescore_sdk-1.4.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8f5fecc72637ffba9c6f5c165830a188",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 27547,
"upload_time": "2024-08-07T06:56:24",
"upload_time_iso_8601": "2024-08-07T06:56:24.596660Z",
"url": "https://files.pythonhosted.org/packages/ce/69/530dc28aead7c54223ec639514d32f93c11b22696b0c9763bbab53f92cf7/slidescore_sdk-1.4.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3ca015f4bbb8934a4b1408b1d05ee32b6d5c7340f5059a8c746114b3b7d32054",
"md5": "69e51ee6f846ef68efd2727abfcee0e5",
"sha256": "cfdb093aeb5d4de02c6384f896209c470a121b706f9e7f1e6e35348ea96f6b92"
},
"downloads": -1,
"filename": "slidescore-sdk-1.4.5.tar.gz",
"has_sig": false,
"md5_digest": "69e51ee6f846ef68efd2727abfcee0e5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 25171,
"upload_time": "2024-08-07T06:56:26",
"upload_time_iso_8601": "2024-08-07T06:56:26.526159Z",
"url": "https://files.pythonhosted.org/packages/3c/a0/15f4bbb8934a4b1408b1d05ee32b6d5c7340f5059a8c746114b3b7d32054/slidescore-sdk-1.4.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-07 06:56:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SlideScore",
"github_project": "SlideScore-python-sdk",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "slidescore-sdk"
}