Skip to content
Morris Swertz edited this page Nov 15, 2015 · 12 revisions

** this contents will be moved to http://github.com/molgenis/molgenis.org **

MOLGENIS REST API v2

For query syntax see RSQL parser.

Entity: Read

Key Type Description
attrs Comma-separated string Defines which fields in the API response to select
_method HTTP method Tunnel request through defined method over default API operation

Request

GET http://your.molgenis.url/api/v2/<entity_name>/<entity_id>
GET http://your.molgenis.url/api/v2/<entity_name>/<entity_id>?attrs=attr0
GET http://your.molgenis.url/api/v2/<entity_name>/<entity_id>?attrs=attr0,attr1
GET http://your.molgenis.url/api/v2/<entity_name>/<entity_id>?attrs=attr0(subattr0,subattr1),attr1(*)
POST http://your.molgenis.url/api/v2/<entity_name>/<entity_id>?_method=GET
POST http://your.molgenis.url/api/v2/<entity_name>/<entity_id>?_method=GET
attrs=attr0(subattr0,subattr1),attr1(*)

Entity: Delete

Request

DELETE http://your.molgenis.url/api/v2/<entity_name>/<entity_id>

Entity collection: Read

Key Type Description
q Query string in RSQL RSQL query to filter the entity collection response
sort Query string in RSQL Defines how entity collection response is sorted
attrs Comma-separated string Defines which fields in the API response to select
start int Offset in resource collection
num int Number of resources to retrieve starting at start
_method HTTP method Tunnel request through defined method over default API operation
GET http://your.molgenis.url/api/v2/<entity_name>
GET http://your.molgenis.url/api/v2/<entity_name>?attrs=attr0
GET http://your.molgenis.url/api/v2/<entity_name>?attrs=attr0,attr1
GET http://your.molgenis.url/api/v2/<entity_name>?attrs=attr0(subattr0,subattr1),attr1(*)
GET http://your.molgenis.url/api/v2/<entity_name>?sort=attr0
GET http://your.molgenis.url/api/v2/<entity_name>?sort=attr0:asc
GET http://your.molgenis.url/api/v2/<entity_name>?sort=attr0:desc
GET http://your.molgenis.url/api/v2/<entity_name>?sort=attr0:desc,attr1
GET http://your.molgenis.url/api/v2/<entity_name>?start=40&num=20
GET http://your.molgenis.url/api/v2/<entity_name>?q=attr0==val
GET http://your.molgenis.url/api/v2/<entity_name>?q=attr0!=val
GET http://your.molgenis.url/api/v2/<entity_name>?q=attr0!=val;q=attr1=ge=5

Entity collection: Aggregation

Key Type Description
q Query string in RSQL RSQL query to filter the entity collection response
aggs Aggregation query string in RSQL Aggregation query to aggregate entities

The aggregation query supports the RSQL selectors 'x', 'y' and 'distinct' and the RSQL operator '=='. The selector 'x' defines the first aggregation attribute name, 'y' defines the second aggregation attribute name, 'distinct' defines the distinct aggregation attribute name.

GET http://your.molgenis.url/api/v2/<entity_name>?aggs=x==attr0
GET http://your.molgenis.url/api/v2/<entity_name>?aggs=x==attr0;y==attr1
GET http://your.molgenis.url/api/v2/<entity_name>?aggs=x==attr0;y==attr1;distinct=attr2
GET http://your.molgenis.url/api/v2/<entity_name>?aggs=x==attr0;y==attr1;distinct=attr2&q=attr4==val

Create entities instances

Request

POST http://your.molgenis.url/api/v2/person
Content-Type: application/json

{entities: [
{
    "age": "101",
    "driverslicence": true
},
{
    "age": "102",
    "driverslicence": true
}
]}

Response

201 Created

Body

{
    location: "/api/v2/Person?q=id=in=("1","2")"
    resources: [{
        href: "/api/v2/Person/1"
    },
    {
        href: "/api/v2/Person/2"
    }]
}

* href: "/api/v2/Person/2" returns a created resource
* location: /api/v2/person/?q=id=in=(1,2) returns all created resources

Update entities instances

Request

PUT http://your.molgenis.url/api/v2/person
Content-Type: application/json

{entities: [
{
    "id": 1,
    "age": "11",
    "driverslicence": true
},
{
    "id": 2,
    "age": "12",
    "driverslicence": true
}
]}

Response

204 No Content

Update only one attribute value of entities instances

Context: if you only want to change one attribute without needing to provide all other attributes:

Request

PUT http://your.molgenis.url/api/v2/person/age
Content-Type: application/json

{entities: [
{
    "id": 1,
    "age": "1"
},
{
    "id": 2,
    "age": "2"
}
]}

Response

204 No Content

Clone this wiki locally