Get Started with the Enact Data Push Service (DPS)

Upon subscribing to the Enact API (which includes access to the Enact DPS), you should be issued a Username and Public API Key from the Enact team.

Please contact [email protected] if you have not, or submit feedback through the menu icon in the top-right of the Enact website.


Using the LCPDelta Python package

With the LCPDelta Python package, you can interact with our Enact DPS as per the following general example:

from lcp_delta import enact

enact_dps_helper = enact.DPSHelper(<USERNAME>, <PUBLIC_KEY>)
enact_dps_helper.<DPS_METHOD>(<HANDLER_METHOD>, <METHOD_PARAMETERS>)
from lcp_delta import enact
import asyncio

async def main():
	enact_dps_helper = enact.DPSHelper(<USERNAME>, <PUBLIC_KEY>)
	await enact_dps_helper.<DPS_METHOD>(<HANDLER_METHOD>, <METHOD_PARAMETERS>)

asyncio.run(main())

The values in the example are as follows:

  • USERNAME: Your Enact API username.
  • PUBLIC_KEY: Your Enact API public key.
  • DPS_METHOD: A specific DPS helper method.
  • HANDLER_METHOD: A method to be executed whenever push data is received.
  • METHOD_PARAMETERS: The DPS helper method parameters that specify and refine your data search.

Pushes received via the Python package will be in pandas DataFrame format.

For details on specific DPS helper methods and parameters, please refer to the Data Push Service section of our API Reference where we include examples from our Python package with each push group.



Using Custom Code

Enact uses the Microsoft ASP.NET SignalR library to allow users to subscribe to data pushes (find out more here). Our connection URL is https://enact-signalrhub.azurewebsites.net/dataHub.

If you are using your own custom code to interact with the Enact DPS directly, you can follow the pattern detailed in the below general examples:

using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.DependencyInjection;

var hubBuilder = new HubConnectionBuilder();
hubBuilder.WithUrl("https://enact-signalrhub.azurewebsites.net/dataHub", options =>
{
	options.AccessTokenProvider = async () => <BEARER_TOKEN_METHOD>();
});
hubBuilder.AddNewtonsoftJsonProtocol();

HubConnection connection = hubBuilder.Build();

bool success = connection.StartAsync().Wait(5000);
if (!success) RunReconnectFunction()

connection.Closed += async () => await <RECONNECT_METHOD>()

<JOIN_RESPONSE> response = connection.InvokeAsync("JoinEnactPush", <JOIN_OBJECT>);
connection.On<PUSH_TYPE>(response.Data.PushName, async (data) => <HANDLER_METHOD>(data))
import * as signalR from '@microsoft/signalr'

const hubBuilder = new signalR.HubConnectionBuilder();
hubBuilder.withUrl('https://enact-signalrhub.azurewebsites.net/dataHub', options =>
{
	accessTokenProvider: () => <BEARER_TOKEN_METHOD>();
});
const connection = hubBuilder.build();

await connection.start();

connection.onclose(error => <RECONNECT_METHOD>())

const response = connection.invoke('JoinEnactPush', <JOIN_OBJECT>);
connection.on(response.data.pushName, data => <HANDLER_METHOD>(data));

The methods and values in the examples are defined as follows:

  • BEARER_TOKEN_METHOD: A method that retrieves your bearer token from the Enact auth endpoint (see Managing Bearer Tokens)
  • RECONNECT_METHOD: A method to reconnect to our DPS if the connection is closed.
  • JOIN_RESPONSE (C#): A small class representing the initial join confirmation response from Enact. For the Series Updates group, for example, it takes the form:
    {
      "seriesId": "exampleSeries",
      "countryId": "exampleCountry"
    }
    
  • JOIN_OBJECT: An object with fields which specify the exact push group to join (see the API Reference for details).
  • PUSH_TYPE (C#): A class representing the push objects to be received from this subscription. These objects are defined for each specific push in the API Reference page.
  • HANDLER_METHOD: A method to be executed whenever push data is received.

Please note that the RECONNECT_METHOD must adhere to exponential back-off when trying to reconnect. Failure to do so could lead to a temporary block on your access. Alternatively, if available, Microsoft's .withAutomaticReconnect() extension could be used instead. We also recommend resubscribing to any DPS groups here again, invoking the JoinEnactPush method as normal.

Pushes received via the DPS directly will be in JSON format, and typically deserialised to an object.

For details on specific Enact DPS push groups, please refer to the Data Push Service section of our our API Reference page.