From f368b3e047d14055bc63899771c782ebbb8c6553 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Mon, 20 Jul 2020 11:31:13 +0100 Subject: Start Public REST API --- test/rest-api.org | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 test/rest-api.org (limited to 'test') diff --git a/test/rest-api.org b/test/rest-api.org new file mode 100644 index 0000000..c797cf3 --- /dev/null +++ b/test/rest-api.org @@ -0,0 +1,93 @@ +* PubSeq REST API + +Here we document the public REST API that comes with PubSeq. The tests +are written and run in the amazing emacs [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html][org-babel]]. Execute a code +block with C-c C-c. You may need to set + +#+begin_src elisp +(org-babel-do-load-languages + 'org-babel-load-languages + '((python . t))) +(setq org-babel-python-command "python3") +#+end_src + +#+RESULTS: +: python3 + +To skip confirmations you may also want to set + +: (setq org-confirm-babel-evaluate nil) + +** Check the version + +#+begin_src python :session +import requests +response = requests.get("http://localhost:5000/api/version") +response_body = response.json() +assert response_body["service"] == "PubSeq", "PubSeq API not found" +response_body +#+end_src + +#+RESULTS: +| service | : | PubSeq | version | : | 0.1 | + +** Fetch EBI XML + +#+begin_src python :session +requests.get("http://localhost:5000/api/ebi/sample-MT32690.1.xml").text +#+end_src + +#+RESULTS: +#+begin_example + + + + COVID-19 PubSeq Sample + + 2697049 + Severe acute respiratory syndrome coronavirus 2 + SARS-CoV-2 + + + + investigation type + + + + sequencing method + + + + collection date + + + + geographic location (latitude) + + DD + + + geographic location (longitude) + + DD + + + geographic location (country and/or sea) + + + + geographic location (region and locality) + + + + environment (material) + + + + ENA-CHECKLIST + ERC000011 + + + + +#+end_example -- cgit v1.2.3