Knowledge base

Warning

If you use the on-premise Usedesk version on your own server, then the URL of your methods will be different. Specify the URL to work with API by contacting our support team - support@usedesk.ru.

List of collections and categories

GET

url: https://api.usedesk.ru/support/{account_id}/list

{account_id} - Knowledge base ID at the system

PHP request example
$baseId = 2;
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
);
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'https://api.usedesk.ru/support/'. $baseId .'/list?' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);

return $result;

The order of articles, categories and collections depends on their order at the system.

Example of a response from server
[
    {
        "id": 26,
        "title": "section",
        "public": 1,
        "order": 0,
		"image": "https://secure.usedesk.ru/upload/support/2/42/15427483037735cb7bb7f6a11874125e83c7d2ece15bf4788fd5f40.png",
        "categories": [
            {
				"id": 34,
				"title": "category",
				"public": 1,
				"order": 1,
				"articles" : {
					{
						"id" : 1,
						"title" : "Article 1",
						"views": 23
    					"rating": {
        					"positive": 5,
        					"negative": 1
    					},
					},
					{
						"id" : 2,
						"title" : "Article 2",
						"views": 46
    					"rating": {
        					"positive": 2,
        					"negative": 3
    					},
					}
				}
			},
            {"id": 38, "title": "category 2", "public": 1, "order": 2, "articles": {}},
            {"id": 40, "title": "category 3", "public": 0, "order": 3, "articles": {}},
            {"id": 42, "title": "category 4", "public": 1, "order": 4, "articles": {}},
            {"id": 44, "title": "category 5", "public": 0, "order": 5, "articles": {}},
        ]
    },
    {
        "id": 38,
        "title": "section 2",
        "public": 1,
        "order": 0,
        "categories": [
            {"id": 70, "title": "category ", "public": 0, "order": 1, "articles": {}},
            {"id": 72, "title": "category 2", "public": 1, "order": 2, "articles": {}},
            {"id": 74, "title": "category 3", "public": 1, "order": 3, "articles": {}},
            {"id": 76, "title": "category 4", "public": 1, "order": 4, "articles": {}},
            {"id": 78, "title": "category 5", "public": 1, "order": 5, "articles": {}},
        ]
    }
]

List of articles

GET

url: https://api.usedesk.ru/support/{account_id}/articles/list

The method returns a list of articles. It gets parameters:

Parameter Value
collection_idsCollection id, separated by commas
category_idsCategory id, separated by commas
article_idsArticle id, separated by commas
count

Number of articles per page

Maximum: 100

Default: 20

pagePage (default 1)
querySearch line of request, it searches by article’s title and text.
type

type - article type,

public - public
private - private

By default, all articles are displayed. If the article is public, but it is at a private category, then if you request with type = public it will not be displayed, because it will be considered private due to the parent category’s privacy setting.

sort

Parameter which is used to sort the articles.

Default: id

Possible values: id, title, category_id, public, created_at

order

Sort order by parameter ‘sort’

Default: asc

Possible values: asc - increase, desc - decrease


PHP request example
$baseId = 2;
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'query' => 'как',
	'count' => 2
);
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'https://api.usedesk.ru/support/'. $baseId .'/articles/list?' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);

return $result;


Example of a response from server
{
    "page": 1,
    "last-page": 5,
    "count": 2,
    "total-count": 10,
    "articles": [
        {
            "id": 96,
            "title": "How to sign in",
            "text": "\u003Cp\u003EPress \u003Cem\u003EStart \u003C\/em\u003E\u003Cbr\u003EFill in all the fields\u003Cbr\u003EConfirm your phone number\u003Cbr\u003ECheck your email \u003C\/p\u003E\u003Cp\u003Eprivate\u003C\/p\u003E",
            "public": 0,
            "order": 4,
    		"is_rating": 0,
    		"rating": {
        		"positive": 0,
        		"negative": 0
    		},
            "category_id": 34,
			"collection_id": 123,
			"views": 23,
            "created_at": "2017-08-02 06:14:41"
        }, {
            "id": 98,
            "title": "How to sign in 2",
            "text": "\u003Cp\u003EPress \u003Cem\u003EStart \u003C\/em\u003E\u003Cbr\u003EFill in all the fields\u003Cbr\u003EConfirm your phone number\u003Cbr\u003ECheck your email \u003C\/p\u003E",
            "public": 1,
            "order": 2,
    		"is_rating": 0,
    		"rating": {
        		"positive": 0,
        		"negative": 0
    		},
            "category_id": 34,
			"collection_id": 123,
			"views": 46,
            "created_at": "2017-09-21 17:47:50"
        }
    ]
}

Single article

GET

url: https://api.usedesk.ru/support/{account_id}/articles/{id}

PHP request example
$baseId = 2;
$articleId = 96;
$data = array(
	'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
);
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, 'https://api.usedesk.ru/support/'. $baseId .'/' . $articleId . '?' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);

return $result;
Example of a response from server
{
    "id": 96,
    "title": "How to sign in",
    "text": "\u003Cp\u003EPress \u003Cem\u003EStart \u003C\/em\u003E\u003Cbr\u003EFill in all the fields\u003Cbr\u003EConfirm your phone number \u003Cbr\u003ECheck your email \u003C\/p\u003E\u003Cp\u003Eprivate\u003C\/p\u003E",
    "public": 0,
    "order": 4,
    "is_rating": 0,
    "rating": {
        "positive": 0,
        "negative": 0
    },
    "category_id": 34,
	"collection_id": 123,
	"views": 46,
    "created_at": "2017-08-02 06:14:41"
}

Description of response parameter:

Parameter Value
idArticle id at the knowledge base
titleArticle title
textArticle text in html
public

Article privacy

● 0 - private
● 1 - public

orderArticle sorting order (from smaller to larger)
is_rating

Is the rating active?

● 0 - disabled
● 1 - enabled

rating:positiveThe number of positive ratings
rating:negativeThe number of negative ratings
category_idParent category id
collection_idCollection id
viewsNumber of views
created_atBase article creation at utc

Add article views

GET

url: https://api.usedesk.ru/support/{account_id}/articles/{id}/add-views

The method changes the number of views. It gets one parameter:

Parameter Value
countNumber of views to add
PHP request example
$baseId = 2;
$articleId = 96;
$data = array(
    'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
    'count' => 3 // Adds 3 views to the article
);
$curl = curl_init();
 
curl_setopt($curl, CURLOPT_URL, 'https://api.usedesk.ru/support/'. $baseId .'/' . $articleId . '/add-views?' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
 
return $result;
Example of a response from server
{
    "res" : 1,
    "views": 15
}

Description of response parameter:

ParameterValue
res

0 - did not record
1 - recorded

views

The total number of views after the request

Add rating to the article

GET

url: https://api.usedesk.ru/support/{account_id}/articles/{id}/change-rating

The method changes the article rating. It gets two parameters:

Parameter Value
count_positiveThe number of positive ratings to add
count_negative

The number of negative ratings you need to add

PHP request example
$baseId = 2;
$articleId = 96;
$data = array(
    'api_token'=> 'e1cbe1c1c9d910ef2ae975215644cb53dd555de4',
	'count_negative' => 3 
	'count_positive' => 3 

);
$curl = curl_init();
 
curl_setopt($curl, CURLOPT_URL, 'https://api.usedesk.ru/support/'. $baseId .'/' . $articleId . '/add-views?' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
 
return $result;
Example of a response from server
{
    "rating": 
	{
        "positive": 1,
        "negative": 123
    }
}

Description of response parameter:

Parameter Value
positive

The total number of positive ratings after the request

negativeThe total number of negative ratings after the request