Getting Table Data (Paged Query)

<< Click to Display Table of Contents >>

Raynet One Data Hub > 14.0 > Administration and User Guide > Advanced Topics > Data API 

Getting Table Data (Paged Query)

This endpoints returns the data using paging. You can choose between the output format (CSV or JSON).

 

Type of Request

GET

 

Endpoint URL

http://[host]:[port]/v1/resultDatabase/<table-name>/paged

 

Query Parameters

Parameter

Required

Description

page

No

The number of the page to query. If omitted, the default value of 1 is taken (the first page).

page_size

No

The number of rows returned per-page. When omitted, the default value of 1000 items per page is used. The valid range for this parameter is 1-1000. Exceeding this range will coerce the value to the closest accepted value.

includeDataTypes

No (default: true)

This parameter is only relevant for CSV file requests.

 

If set to false, then the CSV will receive an extra token after the header name, which contains the desired value type, enclosed by square brackets.

 

If you omit this parameter or set it to true, the returned CSV will not have this extra information, and the CSV column names will be a 1-1 representation of the column names.

 

Headers

Parameter

Required

Description

ApiKey

Yes

Your API key (see chapter Authentication and authorization for more information how to get it).

Accept

Yes

This determines the format of the data. Available supported values are:

 

application/json
text/comma-separated-values

 

Sample (PowerShell)

The following code connects to the instance https://datahahub.local (using SSL and port 443) with authentication token M6KNS9Z-3404R00-Q42E4SG-1G4HKWT and then reads the content of the table CatalogSoftware. It asks for the first page and returns 10 elements at once. Finally, it prints the column names with their types and the links for navigation:

 

$dataHubApiKey = "M6KNS9Z-3404R00-Q42E4SG-1G4HKWT";

$dataHubHostName = "https://datahub.local";

$dataHubPort = 443;

$tableName = "CatalogSoftware";

$pageSize = 10;

$page = 1;

 

$urlAddress = "{0}:{1}/v1/resultDatabase/table/{2}/paged?page={3}&page_size={4}" -$dataHubHostName, $dataHubPort, $tableName, $page, $pageSize

 

$headers = @{};

$headers["ApiKey"] = $dataHubApiKey;

$headers["Accept"] = "application/json";

 

$request = Invoke-WebRequest -Uri $urlAddress -Headers $headers -Method Get;

 

if ($request.StatusCode -eq 200) {

    $parsedContent = ConvertFrom-Json($request);

    Write-Host "Available columns:";

    

    foreach ($item in $parsedContent.columns) {

        Write-Host (" * {0} ({1}) " -$item.name, $item.type);

    }

    Write-Host "";

 

    Write-Host "Number of records:";

    Write-Host $parsedContent.records.Count;

    Write-Host "";

 

    Write-Host "Pages":

    Write-Host (" * First:    {0}" -$parsedContent.pagination.first);

    Write-Host (" * Previous: {0}" -$parsedContent.pagination.previous);

    Write-Host (" * Next:     {0}" -$parsedContent.pagination.next);

    Write-Host (" * Last:     {0}" -$parsedContent.pagination.last);

} else {

    throw "Could not download the file. HTTP code $($req.StatusCode)";    

}

 

This prints the following: (Note: The output may be different depending on available tables)

 

Available columns:

 * Id (String)

 * SoftwareId (String)

 * SoftwareVulnerabilityId (String)

 * Status (String)

 * VersionId (String)

 * ProductId (String)

 * Name (String)

 * Vendor (String)

 * RawVersion (String)

 * Version (String)

 * Architecture (String)

 * Language (String)

 * Website (String)

 * ProductFamily (String)

 * ParentFamily (String)

 * Functionality (String)

 * ReleaseDate (String)

 * EndOfLifeDate (String)

 * Support (String)

 * SoftwareType (String)

 * SoftwareClassification (String)

 * License (String)

 * AdditionalFunctions (String)

 * LatestReleaseDate (String)

 * LatestVersion (String)

 

Number of records:

10

 

Pages :

 * First:    https://datahub.local:443/v1/resultDatabase/resultTable/paged?tableName=Catalog_Software&page=1&page_size=10

 * Previous:

 * Next:     https://datahub.local:443/v1/resultDatabase/resultTable/paged?tableName=Catalog_Software&page=2&page_size=10

 * Last:     https://datahub.local:443/v1/resultDatabase/resultTable/paged?tableName=Catalog_Software&page=233&page_size=10