API Endpoint package
API endpoint
https://app.trustservista.com/api/rest/v2/search
Description
Given a search query, the endpoint will return a list of articles that can be found using the search query.
The request data structure:
DocumentRequest { q (string): query string, size (int, optional): number of results per page (maximum 50, by default 20) page: (int, optional): page number }
Query String Syntax
TrustServista uses exactly the same query string syntax as the ElasticSearch search engine. So, if you are already familiar with searching through ElasticSearch, you are good to go with TrustServista API /search. Otherwise, see https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-query-string-query.html#query-string-syntax.
Here are the fields you could use to form your complex query string:
- “title”: article title
- “author”: article author
- “source”: article’s publisher, for example “USA Today”
- “url”: article’s Web address
- “publishTime”: when the articles was published (timestamp)
- “sentiment”: article’s sentiment – TrustServista API supports following values: “pos” (positive), “neu” (neutral) and “neg” (negative)
- “trustlevel”: an integer representing article’s TrustLevel – values from 0 to 100, with following logical intervals: Low (0 – 24), Medium (25 – 74), Good (75 – 100)
- “clickbait”: clickbait score – values from 0 to 100, with 0 representing 0% chance of being clickbait and 100 representing 100% chance of being clickbait.
This endpoint is used in the TrustServista Web Dashboard to power the multipurpose search bar.
Sample cURL call
curl -X POST -H "X-TRUS-API-Key: your_api_key" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -H "Cache-Control: no-cache" \ -d '{"q": "trump AND afghanistan", "size": "50", "page": "1"}' \ "https://trust.servista.eu/rest/v2/search"