Content API
View content source statistics.
Prerequisites
Ensure that you have fulfilled the prerequisites before making your first call.
1. Set a user scope
SearchUnify users can have one of these five scopes. Each scope has an impact on the calls a user can make. The instructions to change user scope are in Change User Scope (API and SDK).
2. Create an app
At the time of creating an app, you obtain a client ID and client secret. Both are used to ascertain your identity. The process of creating an app has been explained in Get Client ID and Client Secret with an API App.
3. Obtain access and refresh tokens using the app
Access and a refresh tokens are required to be able to use the Content API. The process of generating these tokens has been explained in Get Access and Refresh Token Using curl.
Using Access and Refresh Tokens
The token generation call produces two kinds of tokens: Refresh and Access.
The refresh token expires every 14 days. Store it securely. The sole use of refresh tokens is to generate access tokens.
Access tokens expire every four hours. They authenticate users. It is mandatory to include them in the header of your API calls. The format is -H "authorization: Bearer {{access token}}
"
.
Base URL
https://{{hostname}}/api/v2_cs/
The hostname is the URL of your SearchUnify instance.
Example Base URL
https://mycompany.searchunify.com/api/v2_cs/
Endpoints
Returns all the content sources in an array. Each element in the array is an object. Each object has four properties: id
, name
, label
, and url
.
Parameters
There are no parameters.
Example Request
curl -X GET 'https://mycompany.searchunify.com/dev/api/v2_cs/contentSource/all' \
-H 'Content-Type: application/json' \
-H "authorization: Bearer 9be8fd22c0f9a5438de0c196738a103498eb786c"
Example Response
{
"contentSources": [
{
"id": 231,
"label": "mycompany Blogs",
"name": "mycompany_blogs",
"url": "https://www.mycompany.com/sitemap.xml"
},
{
"id": 234,
"label": "Services",
"name": "mycompany_services",
"url": "https://www.mycompany.com/sitemap.xml"
},
{
"id": 236,
"label": "Solutions",
"name": "mycompany_solutions",
"url": "https://www.mycompany.com/sitemap.xml"
},
{
"id": 237,
"label": "Resources",
"name": "mycompany_resources",
"url": "https://www.mycompany.com/sitemap.xml"
},
{
"id": 239,
"label": "SuCommunity",
"name": "mycompany_community",
"url": "https://community.searchunify.com/api/recent"
},
{
"id": 240,
"label": "Product Documentation",
"name": "mycompany_su_help_center",
"url": "https://docs.searchunify.com/Content/Home.htm"
},
{
"id": 241,
"label": "Videos",
"name": "mycompany_mycompany_videos",
"url": "https://www.googleapis.com"
}
]
}
Returns the id
, label
, name
, url
, and size
of a content source, where size
is the number of documents stored in the content source.
Example Parameters
Parameter | Optional / Required | Description | Data Type |
---|---|---|---|
id
|
Required | The unique number used to identify your content source. Run GET contentSource/all to obtain it. |
string |
Example Request
curl -X GET 'https://mycompany.searchunify.com/dev/api/v2_cs/contentSource/258' \
-H 'Content-Type: application/json' \
-H "authorization: Bearer c687be894301a837691c0ed8345a9f0c22df8eb9"
Example Response
{
"id": 259,
"label": "My Company Slack",
"name": "mycompany_slack",
"url": "https://slack.com",
"size": 126
}
Lists all the objects and fields of a content source in an array. Each element in the array is an object. Each object has four properties: id
, label
, name
, and fields
.
The fields
element is also an object with six properties: id
, name
, label
, type
, isFilterable
, and isSearchable
. The type
property can be an int
, a boolean
, or a string
. isFilterable
is a boolean object. If it is true
, then the field is used as a facet. isSearchable
is also a boolean object. If it is true
, then the data stored in the field can be found through search.
Parameters
Parameter | Optional / Required | Description | Data Type |
---|---|---|---|
id
|
Required | The unique number used to identify your content source. Run GET contentSource/all to obtain it. |
string |
Example Request
curl -X GET 'https://mycompany.searchunify.com/dev/api/v2_cs/contentSource/258/objectAndFields'
-H 'Content-Type: application/json'
-H "authorization: Bearer c687be894301a837691c0ed8345a9f0c22df8eb9"
Example Response
{
"items": [
{
"object": {
"id": 316,
"name": "video",
"label": "Vimeo Content",
"fields": [
{
"id": 4594,
"name": "id",
"label": "id",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4595,
"name": "title",
"label": "Title",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4596,
"name": "post_time",
"label": "Created Date",
"type": "datetime",
"isFilterable": 1,
"isSearchable": 0
},
{
"id": 4597,
"name": "body",
"label": "Description",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4598,
"name": "subtitle",
"label": "Sub Title",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4599,
"name": "view_href",
"label": "View Href",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4600,
"name": "tag",
"label": "Tag",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4601,
"name": "channel_id",
"label": "Channel Id",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4602,
"name": "channel_name",
"label": "Channel Name",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4603,
"name": "user_id",
"label": "User Id",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4604,
"name": "comment",
"label": "comments",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4605,
"name": "thumbnail",
"label": "Thumbnail",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
},
{
"id": 4606,
"name": "channel_type",
"label": "Channel Type",
"type": "string",
"isFilterable": 1,
"isSearchable": 1
}
]
}
}
]
}
Returns all the documents in your content source in an array and the size of the array. Each element in the array is an object.
Parameters
Parameter | Optional / Required | Description | Data Type |
---|---|---|---|
contentSourceId
|
Required | The unique number used to identify your content source. Run GET contentSource/all to obtain it. |
string |
objectId
|
Required | The unique number used to identify an object in a content source. Run GET contentSource/{id} to obtain it. |
string |
from
|
Optional | It's an offset. If from == 10 then the first 10 documents from the index will not be a part of response. |
int |
size
|
Optional | It's used to specify how many docs should be returned. size is always greater than equal to zero and less than equal to 50. |
int |
Example Request
curl -X GET 'https://mycompany.searchunify.com/dev/api/v2_cs/apiData/contentSource/258/object/316/get? \
form=0&size=50' \
-H 'Content-Type: application/json' \
-H "authorization: Bearer feb5754dc810f7e517f9597e6cfc1eacadfefa6e"
Example Response
{
"items": [
{
"id": "610433373",
"contentSource": "mycompany_vimeo_video_library",
"object": "video",
"source": {
"id": "610433373",
"title": "contextual flow",
"post_time": "2019-11-15T08:52:41+00:00",
"body": "Learn about contextual flow and its configuration from admin panel",
"view_href": "https://vimeo.com/610433373",
"channel_id": "0763151",
"user_id": "705412301"
}
},
{
"id": "610433374",
"contentSource": "mycompany_vimeo_video_library",
"object": "video",
"source": {
"id": "610433374",
"title": "Live Salesforce agent",
"post_time": "2019-11-15T07:39:00+00:00",
"body": "This video shall allow you to understand about the connection of a user on the chat client with a live Salesforce support agent",
"view_href": "https://vimeo.com/610433374",
"channel_id": "0763151",
"user_id": "705412301"
}
},
"total_count": "2",
}
Returns all the metadata about a document.
Parameters
Parameter | Optional / Required | Description | Data Type |
---|---|---|---|
contentSourceId
|
Required | The unique number used to identify your content source. Run GET contentSource/all to obtain it. |
string |
objectId
|
Required | The unique number used to identify an object in a content source. Run GET contentSource/{id} to obtain it. |
string |
documentId
|
Required | The unique number used to identify a document in an object. Run GET apiData/contentSource/{contentSourceId}/object/{objectId}/get to obtain it. |
string |
Example Request
curl -X GET 'https://mycompany.searchunify.com/dev/api/v2_cs/apiData/contentSource/258/object/316/document/371817612/get' \
-H 'Content-Type: application/json' \
-H "authorization: Bearer 829f880a543f77f546bb72db44a31b44ee97a82f"
Example Response
{
"response": {
"id": "371817612",
"contentSource": "mycompany_vimeo_video_library",
"object": "video",
"source": {
"id": "371817612",
"title": "New Templates for Search Clients",
"post_time": "2019-11-08T07:18:57+00:00",
"tag": [
"Search clients",
"Customer Experience"
],
"view_href": "https://vimeo.com/371811232",
"channel_id": "1513470",
"user_id": "107864507"
},
"found": true
}
}
Update any content field or document property in your index. The changes are reflected in your index. This call does not alter data on your content source. For instance, you can update a document title in the index without changing it in the content source.
Parameters
Parameter | Optional / Required | Description | Data Type |
---|---|---|---|
contentSourceId
|
Required | The unique number used to identify your content source. Run GET contentSource/all to obtain it. |
string |
objectId
|
Required | The unique number used to identify an object in a content source. Run GET contentSource/{id} to obtain it. |
string |
documentId
|
Required | The unique number used to identify a document in an object. Run GET apiData/contentSource/{contentSourceId}/object/{objectId}/get to obtain it. |
string |
body
|
Required | The parameters in body depend on the data structure used in your content source. For a comprehensive list, run curl -X GET https://mycompany.searchunify.com/dev/api/v2_cs/apiData/contentSource/{{contentSourceId}}/object/{{objectId}}/document/{{documentId}}/get . |
string |
IMPORTANT
This POST call currently doesn't support embedded arrays. It means that in case of a data structure like the following, you cannot update tag
.
{
"post_time": "2019-11-08T07:18:57+00:00",
"tag":
[
"Search clients",
"Customer Experience"
],
"view_href": "https://vimeo.com/371817612",
}
IMPORTANT
post_time
is an integer. Don't enclose it in double quotes.
Example Request
curl -X POST 'https://grazitti.searchunify.com/dev/api/v2_cs/apiData/contentSource/258/object/316/document/371817612/update' \
-H 'Content-Type: application/json' \
-H "authorization: Bearer c6624c94aae0c1f789a12edee717e506629d3e96" \
--data-binary $'{
"id": "371817612",
"title": "New Templates for Search Clients",
"post_time": 1573197537000,
"view_href": "https://vimeo.com/371817612",
"channel_id": "1513670",
"user_id": "103214507"
}'
Example Response
{
Response: "OK"
}
Add one or more documents to your search index. bulkUpload
can be used instead of crawling from the Admin Console when:
- You have only a few documents to add and you don't want to recrawl a large content source
- You want to insert new documents into the search index without first deleting it, which happens when an admin crawls from the Admin Console
PARAMETERS
Parameter | Optional / Required | |
---|---|---|
contentSourceId | Required | The unique number used to identify your content source. Run GET contentSource/all to obtain it. |
objectId | Required | The unique number used to identify an object in a content source. Run GET contentSource/{id} to obtain it. |
body | Required | The parameters in body depend on the data structure used in your content source. For a comprehensive list, run curl -X GET https://mycompany.searchunify.com/dev/api/v2_cs/apiData/contentSource/{{contentSourceId}}/object/{{objectId}}/document/{{documentId}}/get. |
IMPORTANT
This POST call currently doesn't support embedded arrays. It means that in case of a data structure like the following, you cannot update
tag
.{ "post_time": "2019-11-08T07:18:57+00:00", "tag": [ "Search clients", "Customer Experience" ], "view_href": "https://vimeo.com/371817612", }
post_time
is an integer. Don't enclose it in double quotes.
EXAMPLE REQUEST This call inserts three Vimeo videos to your SearchUnify index.
curl -X POST \
https://mycompany.searchunify.com/api/v2_cs/apiData/contentSource/6/object/15/bulkUpload \
-H 'authorization: Bearer 5f64e90fe955a95e16334e512f46f9e3c07ad6eb' \
-H 'content-type: application/json' \
-d '{
"bulkData":[{
"id":"1236",
"content":{
"title": "New Templates for Search Clients - Part 1",
"post_time": 1573197537000,
"view_href": "https://vimeo.com/371817612",
"channel_id": "1513670",
"user_id": "103214507"
}
{
"id":"1237",
"content":{
"title": "New Templates for Search Clients - Part 2",
"post_time": 1573197537010,
"view_href": "https://vimeo.com/371817613",
"channel_id": "1513670",
"user_id": "103214507"
}
{
"id":"1238",
"content":{
"title": "New Templates for Search Clients - Part 3",
"post_time": 1573197537210,
"view_href": "https://vimeo.com/371817614",
"channel_id": "1513670",
"user_id": "103214507"
}
}]
}'
EXAMPLE RESPONSE
{
Response: "OK"
}