Skip to main content

client.KeyLogsAsync()

Logs (CSV)

Returns a CSV of the paid lookups made on a key, with the information recorded against each one.

This method requires your Management Key, which can be found on your accounts page.

You can request a maximum interval of 90 days. Without a start or end date, the interval defaults to the last 21 days.

The Content-Type returned is CSV (text/csv). For a non-200 response it reverts to JSON, with the error code and message in the body.

CSV Format​

The CSV has no header row. Columns, in order:

  1. Timestamp (ISO 8601)
  2. IP address the request was received from
  3. Search term
  4. URL the request originated from
  5. Lookup type
  6. Tags
  7. Lookups consumed
  8. Licensee name (sublicensing keys only)
  9. Source IP address

The source IP column carries the address forwarded in the IDPC-Source-IP header. It is only recorded for keys with IP address forwarding enabled, and only when the header holds a valid IP address. It is empty otherwise.

Data Redaction​

We redact Personally Identifiable Information (PII) in your usage log (including IP, source IP, search term and URL data) weekly.

By default we redact PII older than 28 days. You can change this period from your dashboard.

Set the interval to 0 days to prevent PII collection altogether.

Endpoint​

GET /keys/{key}/lookups

See the API reference for this endpoint.

This operation needs a Management Key. Pass it as the second argument to new IdealPostcodesClient(apiKey, managementKey), or set ManagementKey in the options; the client sends it in the Authorization header. See setup.

Signature​

Task<string> KeyLogsAsync(string key, KeyLogsParams? query = null, CancellationToken cancellationToken = default)

Arguments​

NameTypeRequiredDescription
keystringyesAPI Key
queryKeyLogsParamsnoQuery parameters. Fields under Query Parameters.
cancellationTokenCancellationTokennoCancels the request.

Query Parameters​

Set these on the query argument. Each property is the name in PascalCase, such as PostTown for post_town; required fields are constructor arguments.

NameTypeRequiredDescription
startlongnoStart Timestamp
endlongnoEnd Timestamp
licenseestringnoLicensee Key

Response​

The CSV text, as a string.

Errors​

An HTTP error throws ApiException with the StatusCode, the API error Code and the raw Body. A success response whose body cannot be read throws UnserializableResponseException. Network failures and cancellation throw HttpClient's own HttpRequestException and OperationCanceledException. See error handling.

Example​

key-logs.cscsharp
using IdealPostcodes;

using var client = new IdealPostcodesClient("ak_test", "uk_test");

var csv = await client.KeyLogsAsync("ak_test", new KeyLogsParams
{
Start = DateTimeOffset.UtcNow.AddDays(-7).ToUnixTimeMilliseconds(),
End = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
});

Console.WriteLine(csv);