# Ambar Web API v1.2.0 Ambar Web API documentation - [Files](#files) - [Get File Meta by File Id](#get-file-meta-by-file-id) - [Get File Source by File Id](#get-file-source-by-file-id) - [Get Parsed Text From File by File Id](#get-parsed-text-from-file-by-file-id) - [Download File Content by Secure Uri](#download-file-content-by-secure-uri) - [Download Parsed Text by Secure Uri](#download-parsed-text-by-secure-uri) - [Upload File](#upload-file) - [Hide File](#hide-file) - [Unhide File](#unhide-file) - [Search](#search) - [Search For Documents By Query](#search-for-documents-by-query) - [Retrieve File Highlight by Query and fileId](#retrieve-file-highlight-by-query-and-fileid) - [Retrieve Full File Highlight by Query and fileId](#retrieve-full-file-highlight-by-query-and-fileid) - [Sources](#sources) - [Get Available Sources](#get-available-sources) - [Statistics](#statistics) - [Get Statistics](#get-statistics) - [Tags](#tags) - [Delete Tag From File](#delete-tag-from-file) - [Get Tags](#get-tags) - [Add Tag For File](#add-tag-for-file) - [Thumbnails](#thumbnails) - [Get Thumbnail by Id](#get-thumbnail-by-id) - [Add or Update Thumbnail](#add-or-update-thumbnail) - [Users](#users) - [Login](#login) - [Logout](#logout) # Files ## Get File Meta by File Id GET api/files/direct/:fileId/meta ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |
User email
| | ambar-email-token | String |User token
| ### Success Response HTTP/1.1 200 OK ``` Octet-Stream ``` ### Error Response HTTP/1.1 404 Not Found ``` File meta or content not found ``` ## Get File Source by File Id GET api/files/direct/:fileId/source ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Success Response HTTP/1.1 200 OK ``` Octet-Stream ``` ### Error Response HTTP/1.1 404 Not Found ``` File meta or content not found ``` ## Get Parsed Text From File by File Id GET api/files/direct/:fileId/text ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Success Response HTTP/1.1 200 OK ``` Octet-Stream ``` ### Error Response HTTP/1.1 404 Not Found ``` File meta or content not found ``` ## Download File Content by Secure Uri GET api/files/:uri ### Success Response HTTP/1.1 200 OK ``` Octet-Stream ``` ### Error Response HTTP/1.1 404 Not Found ``` File meta or content not found ``` ## Download Parsed Text by Secure Uri GET api/files/:uri/text ### Success Response HTTP/1.1 200 OK ``` Octet-Stream ``` ### Error Response HTTP/1.1 404 Not Found ``` File meta or content not found ``` ## Upload FileNew source named uiupload with description Automatically created on UI upload will be created if source didn't exist.
User email
| | ambar-email-token | String |User token
| ### Examples Upload File test.txt ``` curl -X POST \ http://ambar_api_address/api/files/uiupload/test.txt \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -F file=@test.txt ``` ### Success Response HTTP/1.1 200 OK ``` { "fileId": xxxxx } ``` ### Error Response HTTP/1.1 400 Bad Request ``` Wrong request data ``` HTTP/1.1 404 Not Found ``` File meta or content not found ``` ## Hide FileHide file by file id
PUT api/files/hide/:fileId ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Success Response HTTP/1.1 200 OK ``` HTTP/1.1 200 OK ``` ### Error Response HTTP/1.1 404 NotFound ``` File not found ``` ## Unhide FileUnhide file by file id
PUT api/files/unhide/:fileId ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Success Response HTTP/1.1 200 OK ``` HTTP/1.1 200 OK ``` ### Error Response HTTP/1.1 404 NotFound ``` File not found ``` # Search ## Search For Documents By Query GET api/search ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email.
| | ambar-email-token | String |User token.
| ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| | query | String |URI_ENCODED query string. Check details of query syntax here.
| | page | Number | **optional**page to return
| | size | Number | **optional**number of results to return per page. Maximum is 100.
| ### Examples Search For `John` ``` curl -i http://ambar_api_address/api/search?query=John ``` ### Success Response HTTP/1.1 200 OK ``` { "total":1, "hits":[ { "sha256":"60a777c59176e98efee98bf16b67983dc981ec4da3eaafcb4d79046d005456f9", "meta":{ "id":"ac8965ab5e07582e0e57cde0e7c4c2d49b955f8b26c779903191893fcb942fa4", "full_name":"//mail.nic.ru/hello@ambar.cloud/linus torvalds talk of tech innovation is bullshit shut up and get the work done fcc chairman wants it to be easier to listen to free fm radio on your smartphone.eml", "short_name":"linus torvalds talk of tech innovation is bullshit shut up and get the work done fcc chairman wants it to be easier to listen to free fm radio on your smartphone.eml", "extension":".eml", "extra":[ ], "source_id":"AmbarEmail", "created_datetime":"2017-02-17 09:22:44.000", "updated_datetime":"2017-02-17 09:22:44.000", "download_uri":"b41c4aaa2999ce42957f087db8e7608970efcedb1eaa40c28336390ecb5373849c955f395258f3dfd7482d4b84d543cdfc23cff8df311276a5e111c0504315c60b159cd2fe2cee20c5470789d9d15e4d7e5fb7c2bc60c29bf9a578e47541fb354dcb5109e49ea9019b2d68c3b35e521a418d9c94f0af55dc79c2442188f039c924d0190c72f488ad77647f2a52aaa267" }, "indexed_datetime":"2017-05-31 13:36:40.400", "file_id":"aa5e000fd79cfed0e839af7073e1ef135e128408f984b9a8e70e34242b49f01a", "content":{ "size":49282, "author":"Slashdot HeadlinesThis method is useful for getting higlights of large files > 30 MB
GET api/search/:fileId ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email.
| | ambar-email-token | String |User token.
| ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| | fileId | String |file fileId
| | query | String |query string
| ### Examples Retrieve Higlights for File with fileId `318be2290125e0a6cfb7229133ba3c4632068ae04942ed5c7c660718d9d41eb3` ``` curl -i http://ambar:8004/api/search/318be2290125e0a6cfb7229133ba3c4632068ae04942ed5c7c660718d9d41eb3?query=John ``` ### Success Response HTTP/1.1 200 OK ``` { "highlight": { "text": [ "Aesop, by some strange accident it seems to have entirelyThis method is useful for getting higlights of large files > 30 MB
GET api/search/:fileId/full ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email.
| | ambar-email-token | String |User token.
| ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| | fileId | String |file fileId
| | query | String |query string
| ### Examples Retrieve Full Higlight for File with fileId `318be2290125e0a6cfb7229133ba3c4632068ae04942ed5c7c660718d9d41eb3` ``` curl -i http://ambar:8004/api/search/318be2290125e0a6cfb7229133ba3c4632068ae04942ed5c7c660718d9d41eb3/full?query=John ``` ### Success Response HTTP/1.1 200 OK ``` Aesop, by some strange accident it seems to have entirelyGet Available Sources (Crawlers Included)
GET api/sources/ ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email.
| | ambar-email-token | String |User token.
| ### Success Response HTTP/1.1 200 OK ``` [ { "id": "Default", "description": "Automatically created on UI upload", "type": "bucket" }, { "id": "Books", "description": "Books crawler", "type": "crawler" }, { "id": "Dropbox", "description": "Dropbox Crawler", "type": "crawler" } ] ``` # Statistics ## Get Statistics GET api/stats ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Success Response HTTP/1.1 200 OK ``` { "contentType": { "total": 2, "minThreshold": 0.1, "data": [ { "name": "application/msword", "value": 1, "sizeDataInBytes": { "count": 1, "min": 91681, "max": 91681, "avg": 91681, "sum": 91681 } } ] }, "procRate": { "data": [ { "date": "2017-04-13", "default": 0 }, { "date": "2017-04-14", "default": 2 } ], "names": [ "default" ] }, "procTotal": { "totalCount": 2, "sizeDataInBytes": { "sum": 147522, "avg": 73761, "min": 55841, "max": 91681 } } } ``` # Tags ## Delete Tag From File DELETE api/tags/:fileId/:tagType/:tagName ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| | fileId | String |File Id to delete tag from.
| | tagType | String |Tag type to delete.
| | tagName | String |Tag name to delete.
| ### Success Response HTTP/1.1 200 OK ``` { "tags":[ { "name":"ocr", "filesCount":3 }, { "name":"test", "filesCount":2 }, { "name":"pdf", "filesCount":1 } ] } ``` ## Get Tags GET api/tags/ ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Success Response HTTP/1.1 200 OK ``` [ { "name":"ocr", "filesCount":3 }, { "name":"test", "filesCount":2 }, { "name":"pdf", "filesCount":1 } ] ``` ## Add Tag For File POST api/tags/:fileId/:tagType/:tagName ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| | fileId | String |File Id to add tag to.
| | tagType | String |Tag type to add.
| | tagName | String |Tag name to add.
| ### Success Response HTTP/1.1 200 OK ``` { "tagId":"e9536a83e64ff03617ab0379d835ac7bbf213bafb95cb42907a56e735472d4fc", "tags":[ { "name":"ocr", "filesCount":3 }, { "name":"test", "filesCount":2 }, { "name":"pdf", "filesCount":1 } ] } ``` # Thumbnails ## Get Thumbnail by Id GET api/thumbs/:id ### Success Response HTTP/1.1 200 OK ``` Octet-Stream ``` ### Error Response HTTP/1.1 404 NotFound ``` HTTP/1.1 404 NotFound ``` ## Add or Update Thumbnail POST api/thumbs/:id ### Success Response HTTP/1.1 200 OK ``` HTTP/1.1 200 OK ``` ### Error Response HTTP/1.1 400 Bad Request ``` Request body is empty ``` # Users ## Login POST api/users/login ### Parameters | Name | Type | Description | |---------|-----------|--------------------------------------| | email | String |User Email
| | password | String |User Password
| ### Success Response HTTP/1.1 200 OK ``` { "token": "504d44935c2ccefb557fd49636a73239147b3895db2f2f...", "ttl": "604800" } ``` ### Error Response HTTP/1.1 400 BadRequest ``` Bad request ``` HTTP/1.1 404 NotFound ``` User with specified email not found ``` HTTP/1.1 409 Conflict ``` User is not in active state ``` HTTP/1.1 401 Unauthorized ``` Wrong password ``` ## Logout POST api/users/logout ### Headers | Name | Type | Description | |---------|-----------|--------------------------------------| | ambar-email | String |User email
| | ambar-email-token | String |User token
| ### Error Response HTTP/1.1 401 Unauthorized ``` Unauthorized ```