Initializing help system before first use

Making REST Requests with the JavaScript API

Developers may need to get data from the Insight server that is not available from any JavaScript API methods by calling one of the Insight Server REST endpoints. The list of all the available REST endpoints is available online in the REST API reference.

REST requests from a VDL or JS Insight view should be automatically include the authentication cookie in the request, as it will be within the same domain and session.

Versioning

The API is versioned using a major.minor versioning scheme. For example, a release of the API might have the version "2.0".
  • When non-breaking changes are introduced, a new minor version of the API will become available, for example "2.1".
  • When breaking changes are introduced, a new major version of the API will become available, for example "3.0".

Clients communicating with the REST API should be lenient to minor changes, so that they can continue to work with the latest minor version of the API without change. For example, the addition of a new field to an object is considered a minor change which the client can and should ignore.

JavaScript Format

All REST resource URLs begin with {serverUrl}/api/. The request is prefixed with the url path to the Insight server {serverUrl}.

The JavaScript API provides a method insight.resolveRestEndpoint, documented in the JavaScript API Reference, adds the necessary prefix to the REST endpoint URL if it is required.

Here is an example of using the generated clientId and secret to get a temporary token then use it to interact with the REST v2 API:
const serverUrl = 'http://localhost:8080';
const clientId = '<your_api_client_id_here>';
const secret = '<your_api_secret_here>';
const restJsonV2 = 'application/vnd.com.fico.xpress.insight.v2+json';


const token = await fetch(`${serverUrl}/api/authentication/token`, {
    method: 'POST',
    mode: 'no-cors',
    credentials: 'include',
    headers: {
        'Content-Type': 'plain/text',
        'Accept': restJsonV2,
    },
    body: JSON.stringify({
        clientId,
        secret,
    }),
}).then(r => r.text());

const appsList = await fetch(`${serverUrl}/api/apps`, {
    method: 'GET',
    headers: {
        'Authorization': `Bearer ${token}`,
        'Accept': restJsonV2,
    }
}).then(r => r.text())

console.log(appsList);

© 2001-2023 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.