I am trying to interact with the Trino historical database to retrieve ADSB data between two times. I have the proper authentication token generation code, and below is the code designed to query Trino and then process the data.
var nextURI: string | undefined;
const queryString = `SELECT * FROM ${startTimeEPOCHMS / 1000} AND ${endTimeEPOCHMS / 1000}`;
const response = await (
'',
queryString,
{
headers: {
Authorization: `Bearer ${}`,
'Content-Type': 'text/plain',
},
}
);
if (response && == 200) {
const body = ;
nextURI = ;
(200);
} else {
throw new Error('Unokay response whilst querying OpenSky');
};
if (nextURI) {
while (nextURI) {
await fetch(nextURI, {
method: 'GET',
headers: {
'Authorization': `Bearer ${}`
}
}).then(async (response) => {
if (response && ) {
// Wait for the data to arrive.
const responseData = await ();
// Print the columns
((, undefined, 2))
if (== "FINISHED" || == "FAILED") {
nextURI = undefined;
} else {
// Go to the next URI.
nextURI =
}
}
}).catch((error) => {
throw error;
});
}
} else {
throw new Error("No nextUri received");
}
It takes 7.46 minutes, uses 385 NextURL links, and returns no data. When I print the columns from the body of the request, I get the following format every time:
[
{
"name": "time",
"type": "integer",
"typeSignature": {
"rawType": "integer",
"arguments": []
}
},
{
"name": "icao24",
"type": "varchar",
"typeSignature": {
"rawType": "varchar",
"arguments": [
{
"kind": "LONG",
"value": 2147483647
}
]
}
},
{
"name": "lat",
"type": "double",
"typeSignature": {
"rawType": "double",
"arguments": []
}
},
{
"name": "lon",
"type": "double",
"typeSignature": {
"rawType": "double",
"arguments": []
}
},
{
"name": "velocity",
"type": "double",
"typeSignature": {
"rawType": "double",
"arguments": []
}
},
{
"name": "heading",
"type": "double",
"typeSignature": {
"rawType": "double",
"arguments": []
}
},
{
"name": "vertrate",
"type": "double",
"typeSignature": {
"rawType": "double",
"arguments": []
}
},
{
"name": "callsign",
"type": "varchar",
"typeSignature": {
"rawType": "varchar",
"arguments": [
{
"kind": "LONG",
"value": 2147483647
}
]
}
},
{
"name": "onground",
"type": "boolean",
"typeSignature": {
"rawType": "boolean",
"arguments": []
}
},
{
"name": "alert",
"type": "boolean",
"typeSignature": {
"rawType": "boolean",
"arguments": []
}
},
{
"name": "spi",
"type": "boolean",
"typeSignature": {
"rawType": "boolean",
"arguments": []
}
},
{
"name": "squawk",
"type": "varchar",
"typeSignature": {
"rawType": "varchar",
"arguments": [
{
"kind": "LONG",
"value": 2147483647
}
]
}
},
{
"name": "baroaltitude",
"type": "double",
"typeSignature": {
"rawType": "double",
"arguments": []
}
},
{
"name": "geoaltitude",
"type": "double",
"rawType": "array",
"arguments": [
{
"kind": "TYPE",
"value": {
"rawType": "integer",
"arguments": []
}
}
]
}
},
{
"name": "hour",
"type": "integer",
"typeSignature": {
"rawType": "integer",
"arguments": []
}
}
]