-
Notifications
You must be signed in to change notification settings - Fork 1
CEDAR REST APIs
This page provides an informal guide to help you quickly get working with CEDAR REST APIs.
First create an account on CEDAR at cedar.metadatacenter.net
. Each registered user will be assigned an API key. For a research group it may make sense to create a central project user and use the user's API key for all CEDAR access.
To find this API key, log in to CEDAR at cedar.metadatacenter.net
and click on the person icon on the top right of the desktop and select the 'Profile' option.
Note this API key. This key is needed for all CEDAR REST calls.
CEDAR templates, elements, and fields are represented using (JSON Schema](http://json-schema.org/). Instances are represented using JSON-LD.
The CEDAR Repository Model defines the representation of these entities. A paper describing this model can be found here. A full description of the model can be found here. A description of the format of metadata instances in the CEDAR repository can be found here.
Note that you can also look at the JSON representing CEDAR instances by opening an instance in the CEDAR tool and clicking on the circle icon on the top right of the screen. This will allow you to eyeball the representation of instances without going through the REST APIs.
Initial documentation of our REST APIs can be found here. The overall documentation is fragmentary at the moment but should be complete shortly. However, the core REST search endpoint is fully documented here.
You can try these endpoints interactively via the Swagger-generated pages, or you can use curl
.
Here are some example curl
commands you can try to retrieve templates and instances:
-
Find all resources that match a search query. For
q=*
all resources will be retrieved.curl -H "Content-Type: application/json" -H "Authorization: apiKey <yourApiKey>" \
-X GET "https://resource.metadatacenter.net/search?q=" ```
This query will return all templates, elements, fields, instances or folders that match the query.
- To find all resources of a particular type use the
resource_types
parameter followed by one or more comma-separated types. Possible values aretemplate
,element
,instance
andfolder
.curl -H "Content-Type: application/json" -H "Authorization: apiKey <yourApiKey>" \
-X GET "https://resource.metadatacenter.net/search?q=&resource_types="
Retrieve all templates and elements:
curl -H "Content-Type: application/json" -H "Authorization: apiKey "
-X GET "https://resource.metadatacenter.net/search?q=*&resource_types=template,element"
```
- To find all instances of a particular template use the
template_id
field to identify the template:curl -H "Content-Type: application/json" -H "Authorization: apiKey <yourApiKey>" \
-X GET "https://resource.metadatacenter.net/search?template_id=" ```
Find all instances of the template with the ID `https://repo.metadatacenter.net/templates/c1199f96-dbd3-4476-8141-1f1fb13e1bca`
```
curl -H "Content-Type: application/json" -H "Authorization: apiKey <yourApiKey>" \
- Retrieve the content of a particular resource:
curl -H "Content-Type: application/json" -H "Authorization: apiKey 5d188fe8-d52f-4773-9750-698a4d2eb557" \
-X GET --header "Accept: application/json" "https://resource.metadatacenter.net//" ``` with: - <resourceType> = {templates|template_elements|template_instances} - <resourceId> is the resource identifier (@id field). Note that the resource identifier must be encoded (e.g., https%3A%2F%2Frepo.metadatacenter.net%2Ftemplate-instances%2F30e39969-1995-47c9-bb74-a086dddced8e).
*Example: Retrieve the content of the template with the ID `https://repo.metadatacenter.net/templates/c1199f96-dbd3-4476-8141-1f1fb13e1bca`*
```
curl -H "Content-Type: application/json" -H "Authorization: apiKey 5d188fe8-d52f-4773-9750-698a4d2eb557" \
-X GET --header 'Accept: application/json' 'https://resource.metadatacenter.net/templates/https%3A%2F%2Frepo.metadatacenter.net%2Ftemplates%2Fc1199f96-dbd3-4476-8141-1f1fb13e1bca"
### Support
If you have questions about these APIs, please subscribe to the [CEDAR Developer Support
mailing list](https://mailman.stanford.edu/mailman/listinfo/cedar-developers).
After subscribing, send messages to `cedar-developers` at `lists.stanford.edu`.