Getting Table Data (Paged Query)

<< Click to Display Table of Contents >>

RayVentory Data Hub > 12.5 u5 > 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: false)

This parameter is only relevant for CSV file requests.

 

If set to true, then the CSV will receive an extra row after headers but before the data, which describe the actual column types (as indicated by the database engine).

 

If you omit this parameter or set it to false, the returned CSV will not have this extra information, but will be then cross-compatible with other CSV-capable software.

 

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}" -f $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}) " -f $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}" -f $parsedContent.pagination.first);

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

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

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

}

else

{

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

}

 

This prints the following:

 

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