Download OpenAPI specification:Download
This document describes the Raffle Search API. It provides the features needed to build a custom user interface for the Raffle Search Engine, and provide signals that can be used to increase the accuracy of search results and provide insights through the Raffle Web App.
Some endpoints rely on an API Tool being created in advance in the Raffle Web App. An API Tool allow you to configure what sources to search in and specify how many results to return. It is possible to have muttiple API Tools for use in different contexts.
API Tools are identified by a unique id that can be obtained by clicking the "Install" button on the API Tool configuration page.
Errors are returned in a standardized format.
{
"code: <http status code>,
"message": "detailed error message"
}
The autocomplete endpoint is used to fetch suggestions based on the input provided by the user so far. The response will be a list of search queries that can be suggested to the user. If no suggestions are found, "null" is returned rather than an empty list.
The suggestions returned by the API are based on actual user queries (i.e. what other users have asked previously). A certain amount of existing queries are required before any suggestions can be generated. Calling this endpoint before a sufficient amount of data is available will result in an error.
uid required | string the id of the search instance (aka the tool UID) |
query required | string the search query provided by the user so far |
limit | integer The number of suggestions to return. |
{- "suggestions": [
- "string"
]
}
The chat endpoint replies to a chat message, based on the results of a search and previous conversation. If there are no relevant search results, it will be indicated by the status property.
A chat reply can reference the search results. These references are
provided as indexes enclosed by square brackets (e.g. [1]
). The
references contain information about the source of the information,
including a title, relevant text snippet, and a url (if available).
If relevant, we will provide a list of related follow up questions that can be suggested to the user. These can be used in subsequent chat requests.
Note that it may take some time to generate the reply. It is highly recommended to display a placeholder to the user while the reply is being fetched. Once the reply is available, the placeholder can then be replaced by the actual reply.
uid required | string Example: uid=D2FF7152-8089-41A9-A65D-E82111A11E49 The id of the search instance. This is also known as the tool UID. |
query required | string the search query provided by the user |
conversation-id | string a unique identifier for a conversation. When provided, the conversation will continue from the latest reply generated with that identifier. If the identifier has not been used before, a new conversation is started. If no identifier is provided, a new conversation is started, and an identifier is returned in the response. |
session-id required | string A unique id identifying the current user session across pages |
preview | boolean If set to true the request will not be used for training or show up in insights |
device | string Enum: "desktop" "mobile" "unknown" The kind of device on which the user performed the chat |
{- "status": "success",
- "reply": "string",
- "conversation_id": "string",
- "follow_up_questions": [
- {
- "question": "string"
}
], - "references": [
- {
- "index": 0,
- "title": "string",
- "url": "string",
- "content": "string",
- "feedback_data": "U29tZSBpbnRlcm5hbCBkYXRh"
}
]
}
Extract a list of conversation ids and urls that can be used for external statistics. The conversation ids are extracted from the DOM of the chat application used in the extension. If multiple relevant topics are discussed in a conversation we choose to return the url from the latest topic discussed.
uid required | string Example: uid=D2FF7152-8089-41A9-A65D-E82111A11E49 The id of the search instance. This is also known as the tool UID. |
from required | string <date> Example: from=1992-01-25 Retrieve data starting from and including this date. |
to required | string <date> Example: to=1992-01-25 Retrieve data before this date. |
{
}
In order to improve search results and provide useful insignts, we track what results turned out most useful. An important signal used for determining this is what results a user is following (i.e. clicking or tapping on).
To allow correlating a result with the user action, whenever the user is following a url from a result, the client must call the feedback endpoint with the feedback data provided together with the result. This feedback data is a base64 encoded string that contains relevant information used internally at Raffle, so it must be sent back in its full original form (i.e. no lower casing or truncation).
type required | string Value: "click" The kind of event. |
feedback_data required | string The data obtained from the |
{- "type": "click",
- "feedback_data": "U29tZSBpbnRlcm5hbCBkYXRh"
}
{- "code": 0,
- "message": "string"
}
The search endpoint can be queried with the question or keywords provided by the user and will respond with a list of search results. Each search result will include the information necessary to display the results back to the user and to provide feedback to Raffle.
A user can perform multiple related searches and for the purpose of retraining and analyzing the data, the related searches must be grouped into sessions. It is the responsibility of the client to provide an identifier that allow us to perform this grouping. An identifier could be a user id, a session id, and simply a random string generated on page load. We will not store the identifier in its raw form on our side, but instead use a hashed version.
Depending on the source of the results and its configuration, the available properties can vary.
For most types of sources, results will be of the type "paragraph", and will contain a title, a url (if available), and a snippet of the relevant section in the original content. The snippet will be wrapped in a "
"-tag for consistentcy with other result types, but will otherwise be a plain text representation of the content, to avoid unintentional formatting of the results. Placeholders will be inserted where the original content contained line breaks, so separating characters can be inserted. An example of a paragraph with line break place holders is
<p>Some text <span class="raffle line-break"></span> Some more text</p>
Results originating from instant answer sources will be of the type "instant_answer". These will not include a title, but can optionally be assigned a url by the author. The content will contain the full html-formatting of the original instant answer. It is the responsibility of the client to ensure that it can be displayed properly. If the instant answer is configured with additional call-to-actions or similar, this will be available in "configuration" property.
Certain sources, like webscrapes, can be configured to extract additional html fragments. These will be returned together with the result, and can be used to annotate the result with additional custom information. The html fragment will be represented in json to simplify the extraction of relevant data on the client side. An example of this json format is shown below. If the fragment was not found on the original page, an empty list of matches are returned.
...
"metadata": [{
"selector": "my-selector"
"matches": [{
"type": "tag",
"tag": "p",
"children": [{
"type": "tag",
"tag": "a",
"attr": {
"href": "/link/",
},
"children": [{
"type": "text"
"data": "link sample text",
}]
}]
}]
}]
...
A big advantage of AI based search is its ability to learn from its usage and improve over time. All search results will include a "feedback_data" property that will allow for this. See the feedback endpoint for more details.
To avoid test searches from being used in retraining or showing up in insights, the searches can be marked as preview, which will disable all tracking of the search.
uid required | string Example: uid=D2FF7152-8089-41A9-A65D-E82111A11E49 The id of the search instance. This is also known as the tool UID. |
session-id required | string A unique id identifying the current user session across pages |
query required | string The search query provided by the user |
preview | boolean If set to true the request will not be used for training or show up in insights |
device | string Enum: "desktop" "mobile" "unknown" The kind of device on which the user performed the search |
{- "results": [
- {
- "type": "paragraph",
- "title": "Changing billing information",
- "content": "<p>You can change your billing information on your settings page</p>",
- "feedback_data": "U29tZSBpbnRlcm5hbCBkYXRh",
- "metadata": { },
- "configuration": { }
}
]
}
The summary endpoint summarizes the results of a given search query. If there is no relevant search results to summarize, this will be indicated by the status property.
A summary can reference the original search results. These references
are provided as indexes enclosed by square brackets (e.g. [1]
). The
references contain information about the source of the information,
including a title, relevant text snippet, and a url (if available).
Note that it may take some time to generate the summary. It is highly recommended to display a placeholder to the user while the summary is being fetched. Once the summary is available, the placeholder can then be replaced by the actual summary.
uid required | string Example: uid=D2FF7152-8089-41A9-A65D-E82111A11E49 The id of the search instance. This is also known as the tool UID. |
query required | string the search query provided by the user |
{- "status": "success",
- "summary": "string",
- "references": [
- {
- "index": 0,
- "title": "string",
- "url": "string",
- "content": "string"
}
]
}
When a user is forwarded to support outside the raffle widget, it will not be reflected in our analytics. You can use this endpoint to notify us that a user was send to support.
uid required | string The uid of the tool that the event should be registered for. |
url required | string The url the user was at when forwarded to support. |
{- "uid": "B753DCD1-E8EA-43E2-8260-85CA862CF640",
}
{- "code": 0,
- "message": "string"
}
Top questions can be used to give the end-user the option to choose from a list of popular search queries. The top questions provided by this endpoints are managed in the Raffle Web App.
Note that an API based search solution doesn't have to provide top questions, and the questions can come from different sources not managed by Raffle.
uid required | string Example: uid=D2FF7152-8089-41A9-A65D-E82111A11E49 The id of the search instance. This is also known as the tool UID. |
{- "questions": [
- {
- "question": "string"
}
]
}