Introduction
Welcome to the YasNah API! You can use our API to access your projects in our system.
At this moment we support seeding data and performing labeling per project via integrations.
You can view code examples in the dark area to the right in shell
.
This API documentation page was created with Slate.
Authentication
To authorize, use this code:
# With shell, you can just pass the correct header with each request
curl "https://api.yasnah.com/..." \
-H "X-Project-Token: 11f8a836dd01e748d6d8abc" \
...
Make sure to replace
11f8a836dd01e748d6d8abc
with corresponding project token.
YasNah uses project token to allow access to the project via an API. To get a project token you need to create an Integration.
Open your project settings, go to integrations page and create a new integration:
Source
- a string that will be used to show who performed an operationToken
- a string that will be used to authorize a call.
We expect for the project token to be included in all your requests to the server in a header that looks like the following:
X-Project-Token: 11f8a836dd01e748d6d8abc
Management
Task batch insert
curl "https://api.yasnah.com/projects/48421cbe68fffee6e32ee6a/tasks/batch" \
-X POST \
-H "accept: application/json" \
-H "X-Project-Token: 11f8a836dd01e748d6d8abc" \
-H "Content-Type: application/json" \
-d \
"[
{
\"question\":\"Do you think it is true?\",
\"text\":\"More than half of all pilots admit to sleeping on the job.\",
\"label\":true
}
]"
The above command returns JSON structured like this:
[
"d64472a27659c22dc982a5c"
]
This endpoint is used to add a collection of tasks to the specified project.
HTTP Request
POST https://api.yasnah.com/projects/{projectId}/tasks/batch
URL Parameters
Parameter | Description |
---|---|
projectId | An id of the project |
Request Parameters
Field | Type | Required |
---|---|---|
body | array of Task | true |
Each Task should should have:
Field | Type | Required | Example |
---|---|---|---|
question | string | true | Do you think it is true? |
text | string | true | More than half of all pilots admit to sleeping on the job. |
label | boolean | false | true |
Labeling
Label a task
curl "https://api.yasnah.com/annotate/d64472a27659c22dc982a5c/label" \
-X PUT \
-H "accept: application/json" \
-H "X-Project-Token: 11f8a836dd01e748d6d8abc" \
-H "Content-Type: application/json" \
-d "{\"label\":true}"
The above command returns an empty response:
{
}
This endpoint is used to label a single task. Consider using it when you have a 3rd party labeling system which might post responses directly into YasNah.
HTTP Request
POST https://api.yasnah.com/annotate/{taskId}/label
URL Parameters
Parameter | Description |
---|---|
taskId | An id of the task |
Request Parameters
Field | Type | Required | Example |
---|---|---|---|
label | boolean | true | true |
Label a task batch
curl "https://api.yasnah.com/annotate/batch/48421cbe68fffee6e32ee6a" \
-X POST \
-H "accept: application/json" \
-H "X-Project-Token: 11f8a836dd01e748d6d8abc" \
-H "Content-Type: application/json" \
-d \
"[
{\"id\":\"d64472a27659c22dc982a5c\",\"label\":true},
{\"id\":\"3f769d58eba286873f4b467\",\"label\":true}
]"
The above command returns a JSON with task id(s) that were successfully labeled:
[
"d64472a27659c22dc982a5c",
"3f769d58eba286873f4b467"
]
If a task with specified id dooes not exist, you will not get in in response
This endpoint is used to label multiple tasks. Consider using it when you have a 3rd party labeling system which might post responses directly into YasNah.
HTTP Request
POST https://api.yasnah.com/annotate/batch/{projectId}
URL Parameters
Parameter | Description |
---|---|
projectId | An id of the project |
Request Parameters
Field | Type | Required |
---|---|---|
body | array of Task Label | true |
Each Task Label should should have:
Field | Type | Required | Example |
---|---|---|---|
id | string | true | d64472a27659c22dc982a5c |
label | boolean | false | true |
Errors
YasNah API uses the following error codes:
Code | Meaning |
---|---|
400 | Bad Request |
401 | Unauthorized |
403 | Forbidden |
404 | Not Found |
500 | Internal Server Error |
503 | Service Unavailable |