17 API
fhimpg edited this page 2024-06-05 11:17:54 +02:00
This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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

{
  "success": 1,
  "token": "MYSECRETTOKEN"
}

renew

Renew access token.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/renew

{
  "success": 1,
  "token": "MYNEWSECRETTOKEN"
}

get

Get complete entries with metadata, document list and link list. Entries can be passed as a comma-separated list in the URL or as an array in a post request.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/get/d51300

curl -X POST -s -d '{"token":"MYSECRETTOKEN","ids":["D12","D34"]}' https://my.domain/v1/get

{
  "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",
      "timestamp": "1634600334",
      "comment": "",
      "size": "175978",
      "mimetype": "text/plain"
    },
    {
      "id": "762955",
      "filename": "MWX_2653X.jpg",
      "timestamp": "1634600334",
      "comment": "Drop",
      "size": "772398",
      "mimetype": "image/jpeg"
    },
    {
      "id": "762956",
      "filename": "SkyTracker.pdf",
      "timestamp": "1634600334",
      "comment": "",
      "size": "1011979",
      "mimetype": "application/pdf"
    }
  ],
  "links": [
    {
      "lid": "4",
      "link": "D51301"
    }
  ]
  "backlinks": [
    {
      "lid": "7",
      "link": "D1234"
    }
  ]
}

getraw

Get complet entry with metadata, document list and link list and raw field names. Entries can be passed as a comma-separated list in the URL or as an array in a post request.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/getraw/d51300

curl -X POST -s -d '{"token":"MYSECRETTOKEN","ids":["D12","D34"]}' https://my.domain/v1/getraw

{
  "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",
      "timestamp": "1634600334",
      "comment": "",
      "size": "175978",
      "mimetype": "text/plain"
    },
    {
      "id": "762955",
      "filename": "MWX_2653X.jpg",
      "timestamp": "1634600334",
      "comment": "Drop",
      "size": "772398",
      "mimetype": "image/jpeg"
    },
    {
      "id": "762956",
      "filename": "SkyTracker.pdf",
      "timestamp": "1634600334",
      "comment": "",
      "size": "1011979",
      "mimetype": "application/pdf"
    }
  ],
  "links": [
    {
      "lid": "4",
      "link": "D51301"
    }
  ]
  "backlinks": [
    {
      "lid": "7",
      "link": "D1234"
    }
  ]
}

bulk

This command ist deprecated, use get instead.

list

Get list of all entries.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/list

{
  "success": 1,
  "ids": [
    "D127",
    "P144",
    "S146",
	:
    "S85823",
    "P85824",
    "P85825",
    "D85826"
  ]
}

types

Get list og document types.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/types

{
  "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

{
  "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

{
  "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

{
  "success": 1,
  "id": "D51306"
}

Options:
{"parent":"<ID>"} 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

{
  "success": 1,
  "id": "D51305"
}

directupload

Upload file from local host. Content has to be base64 encoded.

curl -s -d '{"token":"MYSECRETTOKEN","filename":"test.txt","comment":"COMMENT","content":"ZWluIHRlc3QgdGV4dAo="}' https://my.domain/v1/directupload/D51305

{
  "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

{
  "success": 1,
  "docid": 762963
}

download

Download file.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/download/D51300/762956 --output SkyTracker.pdf

fix

Fix entries and make it read only

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/fix/D51302

{
  "success": 1,
  "id": "D51302"
}

delete

Delete entries from archive

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/delete/D51302

{
  "success": 1,
  "id": "D51302"
}

deletedoc

Delete documents from entry.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/deletedoc/D51300/762956

{
  "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

{
  "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

{
  "success": 1,
  "id": "D51300"
}

search

Search in archive. Keys and fields in one search request will be combined with OR operator. If you leave out fields the search will be done in all fields. 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

{
  "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

{
  "success": 1,
  "id": "D51396"
}

jsonget

Get json data from entry.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://ac.archive.fhi.mpg.de/v1/jsonget/D51461

{
  "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

{
  "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":[<min>,<max>]} array with min and max, for numerical value search.
{"match":"<string>"} search for matching string value.

metaget

Get extended metadata from entry. Entries can be passed as a comma-separated list in the URL or as an array in a post request.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/metaget/S1234

curl -X POST -s -d '{"token":"MYSECRETTOKEN","ids":["D12","D34"]}' https://my.domain/v1/metaget

{
  "success": 1,
  "id": "S1234",
  "tent": "2014-06-20 15:40:32",
  "tcha": "2014-06-20 15:40:32",
  "project": "99",
  "user": "mike",
  "type": "sample",
  "ancestry": [
    "S1232",
    "S1231"
  ],
  "descendants": [
    "S1235",
    "S1236"
  ],
  "f0": "Test Entry",
  "f1": "Mike",
  "f2": "Entry for testing Rest API",
  "f4": "Test, Rest, API",
  "f5": "Comment",
  "jasondata": null,
  "parent": "S1233",
  "childs": [
    "D1895",
    "D1899",
    "D1901"
  ]
}

metadump

Output all metadata you have access to. This request can output a large amount of data and should be used with caution.

curl -s -d '{"token":"MYSECRETTOKEN"}' https://my.domain/v1/metadump