-
Notifications
You must be signed in to change notification settings - Fork 84
REST API Reference
The CodaLab REST API is still under heavy development, and interfaces may change at any time.
We use OAuth 2.0 for authentication and authorization.
All API requests to protected resources must include a valid OAuth bearer token as a HTTP header:
GET /rest/bundles/0x491808200c7e4e2798530d5cf9bdfdd HTTP/1.1
Content-Type: application/json
Authorization: Bearer WM0vteAcGpPhXEGtKmhCGjgVIOvYbB
Unauthorized requests will receive a 403 Forbidden
HTTP response.
The easiest way to get an OAuth token is by requesting a token directly using a username and password.
Content-Type: application/x-www-form-urlencoded
Authorization: Basic Y29kYWxhYl9jbGlfY2xpZW50Og==
Form Parameter | Description |
---|---|
grant_type |
REQUIRED. Value MUST be set to password . |
username |
REQUIRED. The resource owner username or email address. |
password |
REQUIRED. The resource owner password. |
scope |
OPTIONAL. Defaults to default , which provides full access to the user's resources. No other scopes are currently supported, though we may introduce them in the future. |
Example response:
{
"access_token": "NT4xa9noJkBQMxwoL8AikZ6wuGDlUQ",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "HWTsWyqTXmVJuran04OhyXua3k8VlL",
"scope": "default"
}
We follow the JSON API v1.0 specification for the most part, with additional support for bulk operations based on an unofficial Bulk extension.
Some complete examples will be provided to illustrate how this translated into full JSON objects.
Boolean query parameters should be specified as 1
for true and 0
for false.
GET /rest/bundles/<uuid>
GET /rest/bundles/
Query Parameter | Description |
---|---|
keywords |
MULTIPLE. Keywords for a search query, in the same form as in cl search . |
specs |
MULTIPLE. Bundle specs to search for. |
worksheet |
OPTIONAL. ID of the parent worksheet for resolving bundle specs. |
depth |
OPTIONAL. Include all descendants of the found bundles down by this depth. |
POST /rest/bundles
PATCH /rest/bundles
DELETE /rest/bundles
Query Parameter | Description |
---|---|
force=1 |
OPTIONAL. Allow deletion of bundles that have descendants or that appear across multiple worksheets. |
recursive=1 |
OPTIONAL. Delete all bundles downstream of the specified bundles too. |
data-only=1 |
OPTIONAL. Only delete the bundle contents from the bundle store, but keep the bundle metadata. |
dry-run=1 |
OPTIONAL. Just return list of bundles that would be deleted, but do not actually delete. |
Request Example:
{
"data": [
{"type": "bundles", "id": "0x491808200c7e4e2798530d5cf9bdfdd1"},
{"type": "bundles", "id": "0xfbf4b487726248bcbe349932ca6981a3"},
]
}
Response Example:
{
"meta": {
"version": "0.2.0",
"ids": ["0x491808200c7e4e2798530d5cf9bdfdd1", "0xfbf4b487726248bcbe349932ca6981a3"]
}
}
GET /rest/bundles/<uuid>/contents/info/
Query Parameter | Description |
---|---|
depth |
OPTIONAL. Depth to traverse directory tree. |
Example request:
GET /rest/bundles/0x97e9d4bdbecd4a969a7f9d41e2f5dd9c/contents/info/?depth=1
Example response body:
{
"meta": {
"version": "0.2.0"
},
"data": {
"contents": [
{
"type": "file",
"name": "a.txt",
"perm": 420,
"size": 64
},
{
"type": "file",
"name": "b.txt",
"perm": 420,
"size": 22
},
],
"type": "directory",
"name": "0x97e9d4bdbecd4a969a7f9d41e2f5dd9c",
"perm": 493,
"size": 408
}
}
GET /rest/bundles/<uuid>/contents/blob/
Returns the raw data stream containing the contents of the bundle. If the bundle is a directory, the contents will be a tarred and gzipped archive.
PUT /rest/bundles/<uuid>/contents/blob/
Set or replace the contents of the bundle with the file uploaded in the request body. Supports chunked encoding. Directories should be uploaded as tarred+gzipped or zip archives.
POST /rest/bundle-permissions
POST /rest/bundle-actions
GET /rest/worksheets/<uuid>
POST /rest/worksheets/<uuid>/raw
GET /rest/worksheets/
POST /rest/worksheets/
PATCH /rest/worksheets/
DELETE /rest/worksheets/
POST /rest/worksheets-items
POST /rest/worksheets-permissions
GET /rest/user
PATCH /rest/user
GET /rest/users/<user_spec>
GET /rest/users
GET /rest/groups/<group_spec>
GET /rest/groups
Fetch all groups accessible by the authenticated user.
DELETE /rest/groups/<group_spec>
POST /rest/groups
POST /rest/groups/<group_spec>/relationships/admins
POST /rest/groups/<group_spec>/relationships/members
DELETE /rest/groups/<group_spec>/relationships/members