Faqprime APIs

1Answer

Faqprime offers a suite of headless knowledge base APIs that allow developers to extend the platform’s built-in features. These APIs allow you to read data, interoperate with other systems and platforms, and seamlessly scale your help experience.

 

GET API: URL structure (The general format is):

 <https://yourdomain.myfaqprime.com/json/><API-NAME>?keypass=<keypass>&keysecret=<keysecret>&<API-parameters>                

For example:

<https://yourdomain.myfaqprime.com/json/search-api?keypass=3xx3f0xxxxxxxxb92xxxx6734a5ad13ccxxxxx7672baa39&keysecret=834c5xxd897f79fxxxxxx9c1ea6fxxxxcfa3&searchtext=policy>           

 

In this section - List of APIs & their Description

  1. Popular Questions 'popular-api' - Retrieves a list of popular questions for each tag and the count. Each question object includes a question ID, URL and title. By default, it will return a max of 30 questions.
  2. Question info for an ID 'questioninfo-api': Retrieves the URL, title, description, answer count, answer, tags, and category and published status for each ID.
  3. Questions list for a tag 'taginfo-api': This allows retrieving a list of all the questions for each tag and the count. Each question object includes details of the question like ID, URL and title. Further, the list can be retrieved by a page and sorted by created date or trending. By default, it will return a max of 30 questions.
  4. Tag list 'taglist-api' - Displays the total count of tags and retrieves the title of a tag and question count in that tag.
  5. Category info for an ID 'catinfo-api': Retrieves a category title, parent ID, slug, image and its associated questions list or associated subcategory list. (If the category has no subcategory then the response shall contain a question list else subcategory list). In the event, no category configuration is not enabled it will return an error.
  6. Category list 'catlist-api' - Displays the total count of categories and list of categories at the root level with their category ID and title. In the event, no category configuration is not enabled it will return an error.
  7. Knowledge base search 'search-api' - Knowledge base search is based on query parameters that determine what information is returned, and how it’s returned, in the search results. By default, it returns the top 30 search results (if available).
  8. Search autocomplete suggestions 'autocomplete-api':  It shall perform a word match and displays the top 5 matching search query. For example, if "refund" is used as a search text parameter, the autocomplete will find the top 5 applicable search queries that contain "refund" and any term that has an intent keyword "refund".

 

API Parameters

1. popular-api' parameter 

 

NameTypeRequiredDefaultDescription
tagsstringNo-Specify Comma-separated list of tags

2. 'questioninfo-api' parameter 

 

NameTypeRequiredDefaultDescription
qidintegerYes Specify the Question id for which details is sought.

3. 'taginfo-api' parameters

 

NameTypeRequiredDefaultDescription
tagstringYes Specifies the tag name for which details are sought.
pageintegerNo Specifies the current page of the tag. (each page can contains max 30 questions)
sortstring enum("trending", "created")No Specifies the type of results requested. The possible options are: - created - trending 

4. 'taglist-api' parameter

 

NameTypeRequiredDefaultDescription
pageintegerNo0Specifies the current tags page. Defaults to 0.(each page can display a max of 30 tags)

5. 'catinfo-api' parameters

 

NameTypeRequiredDefaultDescription
catidintegerYes The category ID to filter search results by.
sortstring enum("trending", "created")NocreatedSpecifies whether to display questions list in the given category by 'created' or 'trending'. This option is applicable only if given category has no subcategories.
pageintegerNo0Specifies the current questions page for the requested category. Defaults to 0. This option is applicable only if the given category has no subcategories.

6. 'catlist-api' parameter 

 

NameTypeRequiredDefaultDescription
    This API has no parameters.

7. 'search-api' parameters

 

NameTypeRequiredDefaultDescription
searchtextstringYes The search query. 
pageintegerNo0Specifies the current search results page. Defaults to 0 Note: Each response shall display a maximum of 30 search results, to retrieve results beyond 30 results; run the same API by increasing the page count

8. 'autocomplete-api' parameter

 

NameTypeRequiredDefaultDescription
searchtextstringYes  

 

API Responses

Common Response Properties

API PropertiesDescription
error"error:false" - The error is false when there is no error in GET API. "error: true" - The API error response and the reason along with time stamp (UNIX format).
reasonSpecifies the possible reason of error, present only if error:true.
timeCurrent timestamp (UNIX Format), present only if error:true

 

API Specific Response Properties

1. 'popular-api'

 

API PropertiesDescription
responseContains the question list
questionlistEach question list has the following fields:
count: The total count of questions. (max value 30).
question: The sequence no. of the question identified as a question-<seqid>
-id: The unique question ID
- URL: The URL of the question
- title: The title/text of the question`

2. 'questioninfo-api'

 

API PropertiesDescription
responseEach response contains the following fields:
- id: The unique question ID
- URL: The URL of the question
- title: The title/text of the question
- description: Description of the question
- answer count: 0 if no answer else 1.
- answer-0: HTML text of the answer.
- tags: List of tags of the requested question.
- category: category slug of the question.
- hidden: 0 if not hidden else 1. 

3. 'taginfo-api'

 

API PropertiesDescription
responseContains the questionlist
questionlistEach question list has the following fields:
count: The total count of questions. (max value 30).
question: The sequence no. of the question identified as question-<seqid>
id: The unique question ID 
URL: The URL of the question
title: The title/text of the question 

4. 'taglist-api'

 

API PropertiesDescription
responseContains the taglist
taglistEach tag list has the following fields:
count: The total count of tags. (max value 30).
tag: The sequence no. of the tag identified as a tag-<seqid> -
title: Tag Name 
question-count: Number of questions under the given tag.

5. 'catinfo-api'

 

API PropertiesDescription
responseSpecifies the following:
category-id: The ID of the Category
category-title: Category Title.
category-parentid: Parent Category of the given category if root level category then null.
category-slug: category slug
category-image: Image of the category
subcategorylist: Present if the category has subcategories.
questionlist: Present if no subcategory of the given category.
subcategorylistEach subcategory list has the following fields:
count: The total count of subcategories.
subcategory: The sequence no. of the subcategory identified as subcategory-<seqid>
id: Sub Category Id.
title: Sub Category Title.
questionlistEach question list has the following fields:
count: The total count of questions. (max value 30).
question: The sequence no. of the question identified as the question-<seqid>
id: The unique question ID
URL: The URL of the question
title: The title/text of the question

`6. 'catlist-api'

 

API PropertiesDescription
responseSpecifies the category list
categorylistEach category list has the following fields:
count: The total count of categories at the root level.
category: The sequence no. of the category identified as a category-<seqid>
- id: Category Id.
- title: Category Title.

`7. 'search-api'

 

API PropertiesDescription
responseSpecifies the question list
questionlistEach question list has the following fields:
count: The total count of questions. (max value 30).
question: The sequence no. of the question identified as question-<seqid>
- id: The unique question ID
- url: The URL of the question
- title: The title/text of the question

8. 'autocomplete-api'

 

API PropertiesDescription
responseSpecifies the question list
questionlistEach question list has the following fields:
count: The total count of matching search queries. (max 5)
question: The sequence no. of the question identified as question-<seqid>
- id: The unique question ID
- url: The URL of the question
- title: The title/text of the question

 

Sample Code:

<?php

$webaddress = "<https://example.myfaqprime.com/json/>"; // add subdomain as example if your address is example.myfaqprime.com
$keypass = ""; // locate it from admin > control panel
$keysecret = ""; // locate it from admin > control panel

$api = "taginfo-api"; // Your API name
$apiparams = array(
     'tag' => 'faq'
);

$output = faqprime_json_api($webaddress, $api, $keypass, $keysecret, $apiparams);
var_dump($output);

function faqprime_json_api($webaddress, $api, $keypass, $keysecret, $apiparams, $method = 'GET', $request_headers = array())
{
        if (in_array($method, array('GET',  'DELETE')))
        {
                $url = $webaddress.$api."?keypass=$keypass&keysecret=$keysecret&";
                $url .= http_build_query($apiparams);
        }
        else
                $url = $webaddress.$api;

        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_URL,$url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($curl, CURLOPT_MAXREDIRS, 3);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($curl, CURLOPT_TIMEOUT, 30);
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);

        if ($method != 'GET' && in_array($method, array('POST', 'PUT'))) {
                $apiparams = http_build_query(array_merge(array('keypas'=> $keypass, 'keysecret' => $keysecret),$apiparams));
                curl_setopt ($curl, CURLOPT_POSTFIELDS, $apiparams);
        }

        $resp=curl_exec($curl);

        curl_close($curl);
        return json_decode($resp);
}

?>

 

 

 

Did this answer your question?
...