To connect to the Reporting API, all you have to do is perform the following actions.
To whitelist your IPs, simply provide them to Spotware’s service assurance team.
Afterward, you will need to route your connection via Stunnel, a well-known provider of TSL/SSL encryption functionality. To do so, you will need to ensure that Stunnel is deployed successfully and is configured to match our requirements. This configuration can be provided by Spotware’s service assurance team upon request.
After routing your connection via Stunnel, you can freely connect to the Reporting DB using any suitable Postgres client of your choice. The credentials for doing so are summarised below.
Name | Value (Demo) | Value (Live) |
---|---|---|
host |
{stunnelHost} |
{stunnelHost} |
port |
{stunnelPort} |
{stunnelPort} |
username |
{plantId}_{environmentName}_repo |
{plantId}_{environmentName}_repo |
password |
{demoRepoDBPassword} |
{liveRepoDBPassword} |
database |
ctrader_spotware |
ctrader_spotware |
The values of
stunnelHost
andstunnelPort
depend on the way you have chosen to deploy Stunnel. For example, if you are running Stunnel via a Docker container,stunnelHost
would need to reference the container name.
The values of
plantId
,environmentName
,demoRepoDBPassword
, andliveRepoDBPassword
are provided by Spotware’s service assurance team.
In the example below, we use the Npgsql
Nuget package to connect to the Reporting DB via C#. The example retrieves the names of the first 100 entries in the assets
table of the database.
static class Program
{
public static async Task Main() {
string username = "plantOne_live_repo";
string password = "strongPassword";
string stunnelHost = "localhost";
string stunnelPort = "5432";
var connectionString = "Host={stunnelHost};Port={stunnelPort};Username={username};Password={password};Database=ctrader_spotware";
await using var dataSource = NpgsqlDataSource.Create(connectionString);
await using (var cmd = dataSource.CreateCommand("SELECT * FROM \"tables_demo\".\"asset\" LIMIT 100"))
await using (var reader = await cmd.ExecuteReaderAsync())
{
while (await reader.ReadAsync())
{
Console.WriteLine(reader.GetString(1));
}
}
}
}