From 876371e692dad5a7fdc63cf8f3d15c67dd9551c5 Mon Sep 17 00:00:00 2001 From: Michael Wesemann Date: Thu, 7 Apr 2022 15:27:44 +0200 Subject: [PATCH] initial commit --- API.md | 414 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 414 insertions(+) create mode 100644 API.md diff --git a/API.md b/API.md new file mode 100644 index 0000000..1006a44 --- /dev/null +++ b/API.md @@ -0,0 +1,414 @@ +# login +Login into the archive and get access token. Use this token for all other operations. + +`curl -s -d '{"user":"USER","password":"PASSWORD"}' https://my.domain/v1/login` + +```json +{ + "success": 1, + "token": "MYSECRETTOKEN" +} +``` + +# get +Get complete entries with metadata, document list and link list. + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/get/d51300` + +```json +{ + "success": 1, + "id": "D51300", + "tent": "2021-09-03 09:53:08", + "tcha": "2021-09-06 13:57:15", + "project": "DEFAULT", + "user": "mike", + "type": "data", + "Title": "Test Entry", + "Author": "Mike", + "Comment": "Entry for testing Rest API", + "Keywords": "Test, Rest, API", + "Document Type": "UNKNOWN", + "files": [ + { + "id": "762954", + "filename": "c60dens.dat", + "comment": "", + "size": "175978", + "mimetype": "text/plain" + }, + { + "id": "762955", + "filename": "MWX_2653X.jpg", + "comment": "Drop", + "size": "772398", + "mimetype": "image/jpeg" + }, + { + "id": "762956", + "filename": "SkyTracker.pdf", + "comment": "", + "size": "1011979", + "mimetype": "application/pdf" + } + ], + "links": [ + { + "lid": "4", + "link": "D51301" + } + ] +} +``` + + +# getraw +Get complet entry with metadata, document list and link list and raw field names. + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/getraw/d51300` + +```json +{ + "success": 1, + "id": "D51300", + "tent": "2021-09-03 09:53:08", + "tcha": "2021-09-06 13:57:15", + "project": "1", + "user": "mike", + "type": "data", + "f0": "Test Entry", + "f1": "Mike", + "f2": "Entry for testing Rest API", + "f4": "Test, Rest, API", + "f5": "UNKNOWN", + "files": [ + { + "id": "762954", + "filename": "c60dens.dat", + "comment": "", + "size": "175978", + "mimetype": "text/plain" + }, + { + "id": "762955", + "filename": "MWX_2653X.jpg", + "comment": "Drop", + "size": "772398", + "mimetype": "image/jpeg" + }, + { + "id": "762956", + "filename": "SkyTracker.pdf", + "comment": "", + "size": "1011979", + "mimetype": "application/pdf" + } + ], + "links": [ + { + "lid": "4", + "link": "D51301" + } + ] +} +``` + +# list +Get list of all entries. + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/list` + +```json +{ + "success": 1, + "ids": [ + "127", + "144", + "146", + : + "85823", + "85824", + "85825", + "85826" + ] +} +``` + +# types +Get list og document types. + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/types` + +```json +{ + "success": 1, + "types": [ + "data", + "publication", + "sample", + "equipment", + "instrument", + "chemicals", + "gas", + "project" + ] +} +``` + +# projects +Get list of projects. + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/projects` + +```json +{ + "success": 1, + "projects": [ + "DEFAULT", + "PPB" + ] +} +``` + +# fields +get list of content fields for document type + +`curl -s -d '{"token":"MYSECRETTOKEN","type":"data"}' https://my.domain/v1/fields` + +```json +{ + "success": 1, + "fields": { + "f0": [ + "Title", + 0 + ], + "f1": [ + "Author", + 0 + ], + "f2": [ + "Comment", + 0 + ], + "f3": [ + "Abstract", + 0 + ], + "f4": [ + "Keywords", + 1 + ], + "f5": [ + "Document Type", + 0 + ], + "f6": [ + "Methods", + 0 + ], + "f7": [ + "Elements", + 0 + ] + } +} +``` + +# new +Add new entry to archive. Content fields are f0 - f31. + +`curl -s -d '{"token":"MYSECRETTOKEN","type":"data","project":"ppb","f0":"TITLE","f1":"AUTHOR"}' https://my.domain/v1/new` + + +```json +{ + "success": 1, + "id": "D51306" +} +``` + +Options: +`{"parent":""}` set parent for the new entry. + +# edit +Edit entry content. Content fields are f0 - f31. + +`curl -s -d '{"token":"MYSECRETTOKEN","f1":"NEW AUTHOR"}' https://my.domain/v1/edit/D51305` + +```json +{ + "success": 1, + "id": "D51305" +} +``` + +# directupload +Upload file from local host. Content has to be base64 encoded. + +`curl -s -d '{"token":"MYSECRETTOKEN","filename":"test.txt","content":"ZWluIHRlc3QgdGV4dAo="}' https://my.domain/v1/directupload/D51305` +```json +{ + "success": 1, + "docid": 762961 +} +``` + +# urlupload +Upload file from URL. + +`curl -s -d '{"token":"MYSECRETTOKEN","filename":"MWX_2671.jpg","url":"https://x.micw.org/MWX_2671.jpg"}' https://my.domain/v1/urlupload/D51305` + +```json +{ + "success": 1, + "docid": 762963 +} +``` + +# download +Download file. + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/download/D51300/762956 --output SkyTracker.pdf` + +# delete +Delete entries from archive + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/delete/D51302` + +```json +{ + "success": 1, + "id": "D51302" +} +``` + +# deletedoc +Delete documents from entry. + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/deletedoc/D51300/762956` + +```json +{ + "success": 1, + "id": "D51300", + "docid": "762956" +} +``` + +# addlinks +Add links to entry. + +`curl -s -d '{"token":"MYSECRETTOKEN","links":["D51303","D51304"]}' https://my.domain/v1/addlinks/D51300` + +```json +{ + "success": 1, + "id": "D51300", + "links": [ + "D51303", + "D51304" + ] +} +``` + +# deletelinks +Delete links from entry. + +`curl -s -d '{"token":"MYSECRETTOKEN","lids":[44,45,47]}' https://my.domain/v1/deletelinks/D51300` + +```json +{ + "success": 1, + "id": "D51300" +} +``` + +# search +Search in archive. Keys and fields in one search request will be combined with OR operator. If you enter more than one search request they will be combined with AND operator. + +`curl -s -d '{"token":"MYSECRETTOKEN","search":[{"keys":["ertl","schögl"],"fields":[0,1]}]}' https://my.domain/v1/search` + +```json +{ + "success": 1, + "result": [ + "D1411", + "D2031", + "P3564", + "D7386", + "D11970", + "D12437", + "P12909", + "P12910", + "P22783", + "D34278", + "P34583", + "P36356", + "D40773", + "P50853" + ] +} +``` + +# jsonadd +Add json data to entry. + +`curl -s -d '{"token":"MYSECRETTOKEN","jsondata":{"temp":20,"humi":78,"pressure":1017}}' https://my.domain/v1/jsonadd/D51396` + +```json +{ + "success": 1, + "id": "D51396" +} +``` +# jsonget +Get json data from entry. + +`curl -s -d '{"token":"MYSECRETTOKEN"}' https://ac.archive.fhi.mpg.de/v1/jsonget/D51461` + +```json +{ + "success": 1, + "jasondata": { + "temp": 24, + "humi": 58, + "pressure": 1017 + } +} +``` + + + + +# jsonsearch +Search for json data in entries. + +`curl -s -d '{"token":"MYSECRETTOKEN","jsonsearch":"temp"}' https://my.domain/v1/jsonsearch` + +```json +{ + "success": 1, + "result": { + "D51398": { + "temp": 24, + "humi": 58, + "pressure": 1017 + }, + "D51397": { + "temp": 26, + "humi": 39, + "pressure": 1011 + }, + "D51396": { + "temp": 20, + "humi": 78, + "pressure": 1017 + } + } +} +``` + +Options: +```{"range":[,]}``` array with min and max, for numerical value search. +```{"match":""}``` search for matching string value.