Getting Started

The ContentGateway API project is hosted on GitHub, npmjs and unpkg. Note that the GitHub repository with the API source itself is currently private.

Examples are hosted in a public GitHub respository here and hosted versions can be seen here.

You may also like to look at a minimal starter application available here.

Installing

To install the API in to your project with npm:

npm install @activfinancial/cg-api

Or with yarn:

yarn add @activfinancial/cg-api

Alternatively, you can link to the CDN hosted versions of the project:

<script src="https://unpkg.com/@activfinancial/cg-api"></script>

Prerequisites

This project is built on WebAssembly which sets a baseline for browser support. However, we also embrace and assume the availability of a number of modern standards which may require additional polyfilling or transpilation of your source code. These are:

Some examples are built using Web Components. These allow the creation of custom HTML elements that can be easily imported into existing projects. Web Components are designed to be used across most modern browsers and support for them should be readily available.

Using Modules

If you are using a module loader, you can reference the individual parts of the API:

import { connect, FieldId, StatusCode, TableNumber, RelationshipId } from "@activfinancial/cg-api";

Otherwise, the API is available under the global namespace activCgApi:

<script src="node_modules/@activfinancial/cg-api/lib/index.js"></script>
<script>

    activCgApi.connect(/* connect() options. */).then((client) => {
        // "client" now available to make requests.
    });

</script>

Connecting to the ContentGateway

The following snippet demonstrates how to connect and disconnect using the API:

/* global activCgApi */
// You may have to update the userId and password fields below.
const userId = "__ACTIV_FEED_USERNAME__";
const password = "__ACTIV_FEED_PASSWORD__";
const url = "ams://cg-ny4-replay.activfinancial.com/ContentGateway:Service";

(async function() {
    try {
        console.log("Connecting...");

        const client = await activCgApi.connect({
            url,
            userId,
            password
        });

        console.log("Connected");

        console.log("Disconnecting...");
        client.disconnect();

        console.log("Disconnected");
    } catch (e) {
        console.error(`Error: ${e}`);
    }
})();
Try it out in the playground

Compression can be enabled on the ContentGateway connection by specifying parameters in the URL. See here. Note the ContentGateway may enable compression by default, depending on how it is configured.

The return value of connect is an instance of IClient. The properties of IClient are what we'll use to interact with the API. Head to Snapshots and Subscriptions for examples of Client in use.

Also in this Section