Mercurial > hg > orthanc-book
comparison Sphinx/source/users/rest.rst @ 991:1316bc62b5d5
migration to UCLouvain servers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 21 Nov 2023 21:09:02 +0100 |
parents | a6bf749b3c04 |
children | 2e103fb1fa11 |
comparison
equal
deleted
inserted
replaced
990:27b75c653a8b | 991:1316bc62b5d5 |
---|---|
96 <https://stackoverflow.com/questions/463144/php-http-post-fails-when-curl-data-1024/463277#463277>`__:: | 96 <https://stackoverflow.com/questions/463144/php-http-post-fails-when-curl-data-1024/463277#463277>`__:: |
97 | 97 |
98 $ curl -X POST -H "Expect:" http://localhost:8042/instances --data-binary @CT.X.1.2.276.0.7230010.dcm | 98 $ curl -X POST -H "Expect:" http://localhost:8042/instances --data-binary @CT.X.1.2.276.0.7230010.dcm |
99 | 99 |
100 The code distribution of Orthanc contains a `sample Python script | 100 The code distribution of Orthanc contains a `sample Python script |
101 <https://hg.orthanc-server.com/orthanc/file/Orthanc-1.12.1/OrthancServer/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py>`__ | 101 <https://orthanc.uclouvain.be/hg/orthanc/file/Orthanc-1.12.1/OrthancServer/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py>`__ |
102 that recursively upload the content of some folder into Orthanc using | 102 that recursively upload the content of some folder into Orthanc using |
103 the REST API:: | 103 the REST API:: |
104 | 104 |
105 $ python ImportDicomFiles.py localhost 8042 ~/DICOM/ | 105 $ python ImportDicomFiles.py localhost 8042 ~/DICOM/ |
106 | 106 |
108 includes another Python script named ``OrthancImport.py`` that | 108 includes another Python script named ``OrthancImport.py`` that |
109 provides more features than ``ImportDicomFiles.py``. It can notably | 109 provides more features than ``ImportDicomFiles.py``. It can notably |
110 import the content of ``.zip``, ``.tar.gz`` or ``.tar.bz2`` archives | 110 import the content of ``.zip``, ``.tar.gz`` or ``.tar.bz2`` archives |
111 without having to uncompress them first. It also provides more | 111 without having to uncompress them first. It also provides more |
112 comprehensive command-line options. `Check this script out | 112 comprehensive command-line options. `Check this script out |
113 <https://hg.orthanc-server.com/orthanc/file/Orthanc-1.12.1/OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py>`__. | 113 <https://orthanc.uclouvain.be/hg/orthanc/file/Orthanc-1.12.1/OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py>`__. |
114 | 114 |
115 | 115 |
116 .. highlight:: perl | 116 .. highlight:: perl |
117 | 117 |
118 If you are using Powershell (>= 3.0), you can use the following to send a single | 118 If you are using Powershell (>= 3.0), you can use the following to send a single |
450 | 450 |
451 import io | 451 import io |
452 import numpy | 452 import numpy |
453 import requests | 453 import requests |
454 | 454 |
455 r = requests.get('https://demo.orthanc-server.com/instances/6582b1c0-292ad5ab-ba0f088f-f7a1766f-9a29a54f/numpy') | 455 r = requests.get('https://orthanc.uclouvain.be/demo/instances/6582b1c0-292ad5ab-ba0f088f-f7a1766f-9a29a54f/numpy') |
456 r.raise_for_status() | 456 r.raise_for_status() |
457 | 457 |
458 image = numpy.load(io.BytesIO(r.content)) | 458 image = numpy.load(io.BytesIO(r.content)) |
459 print(image.shape) # (1, 358, 512, 1) | 459 print(image.shape) # (1, 358, 512, 1) |
460 | 460 |
469 | 469 |
470 import io | 470 import io |
471 import numpy | 471 import numpy |
472 import requests | 472 import requests |
473 | 473 |
474 r = requests.get('https://demo.orthanc-server.com/series/dc0216d2-a406a5ad-31ef7a78-113ae9d9-29939f9e/numpy') | 474 r = requests.get('https://orthanc.uclouvain.be/demo/series/dc0216d2-a406a5ad-31ef7a78-113ae9d9-29939f9e/numpy') |
475 r.raise_for_status() | 475 r.raise_for_status() |
476 | 476 |
477 image = numpy.load(io.BytesIO(r.content)) | 477 image = numpy.load(io.BytesIO(r.content)) |
478 print(image.shape) # (100, 256, 256, 1) | 478 print(image.shape) # (100, 256, 256, 1) |
479 | 479 |
786 $ curl -X POST http://localhost:8042/modalities/sample/store -d '["d4b46c8e-74b16992-b0f5ca11-f04a60fa-8eb13a88","d5604121-7d613ce6-c315a5-a77b3cf3-9c253b23","cb855110-5f4da420-ec9dc9cb-2af6a9bb-dcbd180e"]' | 786 $ curl -X POST http://localhost:8042/modalities/sample/store -d '["d4b46c8e-74b16992-b0f5ca11-f04a60fa-8eb13a88","d5604121-7d613ce6-c315a5-a77b3cf3-9c253b23","cb855110-5f4da420-ec9dc9cb-2af6a9bb-dcbd180e"]' |
787 | 787 |
788 The list of the resources to be sent are given as a JSON array. In | 788 The list of the resources to be sent are given as a JSON array. In |
789 this case, a single DICOM connection is used. `Sample code is | 789 this case, a single DICOM connection is used. `Sample code is |
790 available | 790 available |
791 <https://hg.orthanc-server.com/orthanc/file/default/OrthancServer/Resources/Samples/Python/HighPerformanceAutoRouting.py>`__. | 791 <https://orthanc.uclouvain.be/hg/orthanc/file/default/OrthancServer/Resources/Samples/Python/HighPerformanceAutoRouting.py>`__. |
792 | 792 |
793 Note that the list of resources to be sent can include the | 793 Note that the list of resources to be sent can include the |
794 :ref:`Orthanc identifiers <orthanc-ids>` of entire patients, | 794 :ref:`Orthanc identifiers <orthanc-ids>` of entire patients, |
795 studies or series as well. | 795 studies or series as well. |
796 | 796 |
1040 }' | 1040 }' |
1041 | 1041 |
1042 Setting the ``Expand`` field to ``true`` in the POST body of the | 1042 Setting the ``Expand`` field to ``true`` in the POST body of the |
1043 query will automatically report details about each study:: | 1043 query will automatically report details about each study:: |
1044 | 1044 |
1045 $ curl https://demo.orthanc-server.com/tools/find -d '{"Level":"Study","Query":{"PatientName":"KNIX"}}' | 1045 $ curl https://orthanc.uclouvain.be/demo/tools/find -d '{"Level":"Study","Query":{"PatientName":"KNIX"}}' |
1046 [ | 1046 [ |
1047 "b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0" | 1047 "b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0" |
1048 ] | 1048 ] |
1049 $ curl https://demo.orthanc-server.com/tools/find -d '{"Level":"Study","Query":{"PatientName":"KNIX"},"Expand":true}' | 1049 $ curl https://orthanc.uclouvain.be/demo/tools/find -d '{"Level":"Study","Query":{"PatientName":"KNIX"},"Expand":true}' |
1050 [ | 1050 [ |
1051 { | 1051 { |
1052 "ID" : "b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0", | 1052 "ID" : "b9c08539-26f93bde-c81ab0d7-bffaf2cb-a4d0bdd0", |
1053 "IsStable" : true, | 1053 "IsStable" : true, |
1054 "LastUpdate" : "20180414T091528", | 1054 "LastUpdate" : "20180414T091528", |
1235 sequence number the changes must be returned:: | 1235 sequence number the changes must be returned:: |
1236 | 1236 |
1237 $ curl 'http://localhost:8042/changes?limit=100&since=922' | 1237 $ curl 'http://localhost:8042/changes?limit=100&since=922' |
1238 | 1238 |
1239 A `sample code in the source distribution | 1239 A `sample code in the source distribution |
1240 <https://hg.orthanc-server.com/orthanc/file/default/OrthancServer/Resources/Samples/Python/ChangesLoop.py>`__ | 1240 <https://orthanc.uclouvain.be/hg/orthanc/file/default/OrthancServer/Resources/Samples/Python/ChangesLoop.py>`__ |
1241 shows how to use this Changes API to implement a polling loop. | 1241 shows how to use this Changes API to implement a polling loop. |
1242 | 1242 |
1243 | 1243 |
1244 Deleting resources from Orthanc | 1244 Deleting resources from Orthanc |
1245 ------------------------------- | 1245 ------------------------------- |
1338 * A :ref:`FAQ entry <rest-samples>` lists where you can find more | 1338 * A :ref:`FAQ entry <rest-samples>` lists where you can find more |
1339 advanced samples of the REST API of Orthanc. | 1339 advanced samples of the REST API of Orthanc. |
1340 * A :ref:`short reference of the REST API of Orthanc <cheatsheet>` is | 1340 * A :ref:`short reference of the REST API of Orthanc <cheatsheet>` is |
1341 part of the Orthanc Book. | 1341 part of the Orthanc Book. |
1342 * The full documentation of the REST API in the OpenAPI/Swagger format | 1342 * The full documentation of the REST API in the OpenAPI/Swagger format |
1343 is `available online <https://api.orthanc-server.com/>`__. This | 1343 is `available online <https://orthanc.uclouvain.be/api/>`__. This |
1344 reference is automatically generated from the source code of | 1344 reference is automatically generated from the source code of |
1345 Orthanc. | 1345 Orthanc. |