Class: platform.HttpClient

platform.platform.HttpClient()

new platform.HttpClient()

The HttpClient type.

Source:

Methods

executeProblogQuery(params) → {Promise.<Object>}

Call the execute-problog-query platform endpoint.

Parameters:
Name Type Description
params Object

the request payload.

Source:
Returns:

the platform response.

Type
Promise.<Object>

executeSqlQuery(params) → {Promise.<Object>}

Call the execute-sql-query platform endpoint.

Parameters:
Name Type Description
params Object

the request payload.

Source:
Returns:

the platform response.

Type
Promise.<Object>

fetch(payload) → {Promise.<Object>}

Call the platform JSON-RPC endpoint.

Parameters:
Name Type Description
payload Object

the request payload.

License:
  • The specification can be found at https://www.jsonrpc.org/specification.
Source:
Returns:

the platform response.

Type
Promise.<Object>

findObjects(params) → {Promise.<Object>}

Call the find-objects platform endpoint.

Parameters:
Name Type Description
params

the request payload.

Source:
Returns:

the platform response.

Type
Promise.<Object>

findTerms(params) → {Promise.<Object>}

Call the find-terms platform endpoint.

Parameters:
Name Type Description
params

the request payload.

Source:
Returns:

the platform response.

Type
Promise.<Object>

getBaseUrl() → {string}

Returns the API base URL.

Source:
Returns:

the API base URL.

Type
string

getFlattenedObjects(params) → {Promise.<Array.<Object>>}

Call the get-flattened-objects platform endpoint.

Parameters:
Name Type Description
params

the request payload.

Source:
Returns:

the platform response.

Type
Promise.<Array.<Object>>

getObjects(params) → {Promise.<Array.<Object>>}

Call the get-objects platform endpoint.

Parameters:
Name Type Description
params

the request payload.

Source:
Returns:

the platform response.

Type
Promise.<Array.<Object>>

getToken() → {string}

Returns the API token.

Source:
Returns:

the API token.

Type
string

hasAutodetect()

Checks if the API token and base URL have been automatically set.

Source:
Returns:

true if the API token and base URL have been automatically set during [[init]].

hasBaseUrl() → {boolean}

Checks if the API base URL is set.

Source:
Returns:

true iif the API base URL is set, false otherwise.

Type
boolean

hasToken() → {boolean}

Checks if the API token is set.

Source:
Returns:

returns true iif the API token is set, false otherwise.

Type
boolean

init(baseUrl, token)

Initializes the Http client.

If you omit a parameter, we will try to autodetect it. For token, we try to find it on the query string. Ex: ?token=your_api_token. For baseUrl, we try to find it from the referrer.

Parameters:
Name Type Description
baseUrl string

the base URL eg. https://www.company.computablefacts.com

token string

the token.

Source:

setBaseUrl(url)

Set the API base URL.

Parameters:
Name Type Description
url string

the API base URL.

Source:

setToken(token)

Set the API token.

Parameters:
Name Type Description
token string

The API token.

Source:

sinkEvent(type, propNames, propValues) → {Promise.<Object>}

Sink a single event.

Parameters:
Name Type Description
type string

the event type.

propNames Array.<string>

the event property names.

propValues Array.<string>

the event property values.

Source:
Returns:

the created fact.

Type
Promise.<Object>

sourceEvents(type, propNames, propPatterns, maxNbResults, format) → {Promise.<(Array.<Object>|Array.<Array.<string>>)>}

Source one or more events.

Parameters:
Name Type Description
type string

the event type.

propNames Array.<string>

the event property names.

propPatterns Object

the list of patterns to match.

maxNbResults number

the maximum number of events to return.

format string

the returned events format. 'objects' returns an Array<Object>. Both 'arrays' and 'arrays_with_header' return an Array<Array<string>>.

Source:
Returns:

an array of events.

Type
Promise.<(Array.<Object>|Array.<Array.<string>>)>

sourceEventsAsArrays(type, propNames, propPatterns, maxNbResults) → {Promise.<Array.<Array.<string>>>}

Source one or more events.

Parameters:
Name Type Description
type string

the event type.

propNames Array.<string>

the event property names.

propPatterns Array.<Object>

the list of patterns to match.

maxNbResults number

the maximum number of events to return.

Source:
Returns:

an array of events.

Type
Promise.<Array.<Array.<string>>>

sourceEventsAsObjects(type, propNames, propPatterns, maxNbResults) → {Promise.<Array.<Object>>}

Source one or more events.

Parameters:
Name Type Description
type string

the event type.

propNames Array.<string>

the event property names.

propPatterns Array.<Object>

the list of patterns to match.

maxNbResults number

the maximum number of events to return.

Source:
Returns:

an array of events.

Type
Promise.<Array.<Object>>

whoAmI() → {Promise.<Object>}

Returns the user information based on the API token.

Source:
Returns:

the user permissions and authorizations.

Type
Promise.<Object>

(inner) fetch(endpoint, body, …customConfig) → {Promise.<Object>}

Execute a Http request to a given platform endpoint.

Parameters:
Name Type Attributes Description
endpoint string

the platform endpoint.

body Object

the request payload.

customConfig * <repeatable>

the Http request configuration.

Source:
Returns:

the platform response.

Type
Promise.<Object>