- Previous: Events API
- Up: Overview
- Next: Links API
Search API
The Search API allows you to find content stored in Egnyte based on filenames, metadata, and text content. Searches are performed in the context of the user token being passed. Accordingly, a user will only see results for contents they have permission to access. The search API has been extended to support searching for metadata fields in files, versions, or folders. When searching metadata, call the API with a POST request to /pubapi/v1/search with a JSON body.
Search (version 1)
Request Examples
GET /pubapi/v1/search?query=localcloudpress HTTP/1.1 Host: apidemo.egnyte.com Authorization: Bearer 68zc95e3xv954u6k3hbnma3q
curl -v -H "Authorization: Bearer 68zc95e3xv954u6k3hbnma3q" \ https://apidemo.egnyte.com/pubapi/v1/search?query=localcloudpress
Sample Response Body
{ "results":[{ "name":"LocalCloudPress.doc", "path":"/Shared/Documents/Sales/Proposals/LocalCloudPress.doc", "type":"application/msword", "size":28672, "snippet":"Version5Version 45\nVersion 3\n\ngnyte brings its storage cloud closer to home\n\nFebruary 17, 2019\n\nhtt", "entry_id":"2c8e1083-47f8-4d57-94dc-fd05429b7ec3", "group_id": "61ed8373-6ff8-493f-8c6f-g4d8a05867243", "last_modified":"2020-01-14T22:19:29Z", "uploaded_by":"David Pfeffer", "uploaded_by_username":"david", "num_versions":1, "snippet_html":"Version5Version 45\nVersion 3\n\ngnyte brings its storage cloud closer to home\n\nFebruary 17, 2019\n\nhtt", "is_folder":false }], "total_count":20, "offset":0, "count":1 }
Request Parameters
Parameter | Description | Required | Possible Values |
---|---|---|---|
query | The search string you want to find. | Yes | string, 100 ≥ character length ≥ 3 |
offset | The 0-based index of the initial record being requested. | No | Any integer ≥ 0 |
count | The number of entries per page | No | Any integer [1, 20] |
folder | Limit the result set to only items contained in the specified folder and all of its descendants. Note that like our file system events API, the folder parameter must be appropriately url-encoded. For example, a path of "/Shared/Documents 2/images", when encoded would become "/Shared/Documents%202/images" | No | Valid folder path |
modified_before | Limit the results set to items modified before the specified ISO-8601 timestamp (e.g. 2020-08-01T18:43:23Z) | No | ISO-8601 timestamp |
modified_after | Limit the results set to items modified after the specified ISO-8601 timestamp. (e.g. 2020-08-01T18:43:23Z) | No | ISO-8601 timestamp |
uploaded_before | Limit the results set to items uploaded before the specified ISO-8601 timestamp (e.g. 2020-08-01T18:43:23Z) | No | ISO-8601 timestamp |
uploaded_after | Limit the results set to items uploaded after the specified ISO-8601 timestamp. (e.g. 2020-08-01T18:43:23Z) | No | ISO-8601 timestamp |
type | Which item types should be searched. | No | FOLDER, FILE |
snippet_requested | Specifies whether search results should contain snippets. If set to "false", the search results will contain empty snippets. | No | true (default), false |
sort_by | The field that should be used for sorting. Results are sorted using score by default. | No | last_modified, size, name, score |
sort_direction | The direction of the sort. | No | ascending, descending |
file_query_fields | Search for files using specific fields. | No | One of ALL, FILENAME, COMMENTS, CONTENT |
folder_query_fields | Search for folders using specific fields. | No |
One of ALL, FOLDERNAME, DESCRIPTION
|
query_operator | Search for all words or any of the words. | No | ANY, ALL |
Response Parameters
Element | Description |
---|---|
count | The number of results returned. |
total_count | Use to see if there are more than {total count} results. If the number of results is less than or equal to {total count}, it will return the number of results. Else, returns {total count} + 1. |
offset | The 0-based index of the last result in the current set of results, this value should be used as offset value while requesting the subsequent page. |
results | A JSON array that holds all of the matched content. |
name | The name of the file. |
path | The path to the file in Egnyte. |
type | The MIME type of the file. |
size | The size of the file in bytes. |
snippet | A plain text snippet of the text containing the matched content. |
snippet_html | An HTML formatted snippet of the text containing the matched content. |
entry_id | A GUID for that particular instance of a file. |
last_modified | The ISO-8601 formatted timestamp representing the last modified date of the file. |
uploaded_by | The formatted name of the user who uploaded the file. |
uploaded_by_username | The username of the user who uploaded the file. |
num_versions | The number of versions of the file available. |
is_folder | A boolean value stating if the object is a file or folder. Please note that, currently, this API only returns file objects. |
hasMore |
Returns true if there are more results than were returned.
|
custom_properties
|
The json of the custom metadata values of the file or folder
|
Search (version 2 with custom metadata)
Request Examples
POST /pubapi/v2/search HTTP/1.1 Host: apidemo.egnyte.com Authorization: Bearer 68zc95e3xv954u6k3hbnma3q { "offset": 0, "count": 20, "namespaces": [ "namespace1", "namespace2" ], "custom_metadata": [ { "namespace": "bear", "key": "the name", "operator": "EQUALS", "value": "hi" } ] }
curl -v -H "Authorization: Bearer 68zc95e3xv954u6k3hbnma3q" \ -H "Content-Type: application/json" \ -d '{"query":"test", "custom_metadata":{"namespace":"bear", "key":"the name", "operator":"EQUALS", "value":"hi"}}' \ -X POST https://apidemo.egnyte.com/pubapi/v2/search
Sample Response Body
{ "count": 1, "total_count": 1, "hasMore": false, "results": [ { "num_versions": 0, "name": "temp_image.jpg", "custom_properties": [ { "scope": "public", "namespace": "bear", "value": "hi", "key": "the name" }, { "scope": "public", "namespace": "bear", "value": "another value", "key": "a key not searched for" }, { "scope": "public", "namespace": "namespace1", "value": "value1", "key": "key1", }, { "scope": "public", "namespace": "namespace1", "value": "", "key": "key2" } ], "uploaded_by_username": "gyang", "snippet": "", "last_modified": "2020-08-27T01:31:00Z", "entry_id": "1603e372-75f2-4b9f-af74-080dec5e4aef", "is_folder": false, "uploaded_by": "Grant Yanng", "path": "/Shared/images/temp_image.jpg", "group_id": "1234567c-ac62-222f-a5d5-e84aaa4050f0", "type": "image/jpeg", "snippet_html": "", "size": 80972 } ], "offset": 0 }
Request Parameters
Parameter | Description | Required | Possible Values |
---|---|---|---|
query | The search string you want to find. | Yes. Either this field or custom_metadata is required but both may be used at the same time and the search is further filtered. |
string, 100 ≥ character length ≥ 3 |
offset | The 0-based index of the initial record being requested. | No | Any integer ≥ 0 |
count | The number of entries per page | No | Any integer [1, 20] |
folder | Limit the result set to only items contained in the specified folder and all of its descendants. Note that unlike v1, because this is in the JSON body, the folder parameter should NOT be url-encoded. | No | Valid folder path |
modified_before | Limit to results before the specified Unix timestamp in milliseconds | No | Unix timestamp in milliseconds |
modified_after | Limit to results after the specified Unix timestamp in milliseconds | No | Unix timestamp in milliseconds |
type | Which item types should be searched. | No | FOLDER, FILE. By default we support both, e.g. ALL. |
snippet_requested | Specifies whether search results should contain snippets. If set to "false", the search results will contain empty snippets. | No | true (default), false |
custom_metadata | Json containing values to be searched | Yes. Either this field or query is required but both may be used at the same time and the search is further filtered. | See below Table |
namespaces | Array of strings containing the name of the namespaces requested. Note that the namespace will only be returned if there is a value in any of the fields. | No | Any valid namespace name |
sort_by | The field that should be used for sorting. Results are sorted using score by default. | No | last_modified, size, name, score |
sort_direction | The direction of the sort. | No | ascending, descending |
query_operator | Search for all words or any of the words. | No | ANY, ALL |
uploaded_before | Limit to results uploaded before the specified Unix timestamp in milliseconds | No | Unix timestamp in milliseconds |
uploaded_after | Limit to results uploaded after the specified Unix timestamp in milliseconds | No | Unix timestamp in milliseconds |
file_query_fields | Search for files using specific fields. | No | One or more of ALL, FILENAME, COMMENTS, CONTENT |
folder_query_fields | Search for folders using specific fields. | No | One or more of ALL, FOLDERNAME, DESCRIPTION |
Custom Metadata JSON
Parameter |
Description |
Required |
Possible Values |
namespace |
Name of namespace |
Yes |
A valid namespace name |
key |
Key to search for |
Yes |
A valid key. All values will be “AND” searched |
operator |
Search operator (List mentioned above) |
Yes |
EQUALS, BETWEEN, GREATER_THAN, LESS_THAN, CONTAINS, IN, HAS_KEY, SUB_SET |
value |
Value for operator EQUALS, GREATER_THAN, LESS_THAN, CONTAINS |
No (one of “value”, “values”, or “range”is required) |
The value to search on. The value for the date should be in milliseconds. |
values |
List of values for operator IN |
No (one of “value”, “values”, or “range”is required) |
A valid custom metadata value |
range |
Range of values for operator BETWEEN |
No (one of “value”, “values”, or “range”is required) |
See below |
start |
Start of range which includes the start value, e.g. >= |
No, unless range is used |
A valid integer, float, or date in Unix timestamp in milliseconds. |
end |
End of range but does not include the end range value, e.g. < only |
No, unless range is used |
A valid integer, float, or date in Unix timestamp in milliseconds. |
Response Parameters
Element | Description |
---|---|
count | The number of results returned. |
total_count | Use to see if there are more than {total count} results. If the number of results is less than or equal to {total count}, it will return the number of results. Else, returns {total count} + 1. |
offset | The 0-based index of the last result in the current set of results, this value should be used as offset value while requesting the subsequent page. |
results | A JSON array that holds all of the matched content. |
name | The name of the file. |
path | The path to the file in Egnyte. |
type | The MIME type of the file. |
size | The size of the file in bytes. |
snippet | A plain text snippet of the text containing the matched content. |
snippet_html | An HTML formatted snippet of the text containing the matched content. |
entry_id | A GUID for that particular instance of a file. |
last_modified | The ISO-8601 formatted timestamp representing the last modified date of the file. |
uploaded_by | The formatted name of the user who uploaded the file. |
uploaded_by_username | The username of the user who uploaded the file. |
num_versions | The number of versions of the file available. |
is_folder | A boolean value stating if the object is a file or folder. Please note that, currently, this API only returns file objects. |
custom_properties | The json of the custom metadata values of the file or folder |
hasMore | Returns true if there are more results than were returned. |
score | A score denoting the relevance of the search result. |
- Previous: Events API
- Up: Overview
- Next: Links API
Docs Navigation
- Overview
- Getting Started
- Authentication
- File System API
- Permissions API
- Events API
- Search API
- Links API
- Workflow API
- User Management API
- Group Management API
- Audit Reporting API v2
- Trash API
- Comments API
- Metadata API
- Embedded UI API
- Bookmarks API
- User Insights API
- Folder Options API
- Project Folder API
- UI Integration Framework
- Controlled Document Management API
- Best Practices
- Mobile Development
- Other Applications
- Webhooks
- Secure and Govern API
- Audit Reporting API V1
- MSP API