API endpoint for Aircraft and Positions Reported Totals?

I’m writing a script which gathers the Totals for Aircraft Reported and Positions Reported, for a number of different sites, and performs some mathematical analysis, essentially using nearby sites as a baseline for assessing site changes. I’m referring to these numbers highlighted in red.

Aircraft reported
Positions reported

I just want the numbers in some delimited form so they can be parsed and stored in arrays for use. For example for the first example above I want something like

128,1481,1446,1549,...

or perhaps

128
1481
1446
1549
...

As a PiAware feeder with an Enterprise account, I’m wondering if there is a way to get these via an API call or some official method? I’ve scoured around and not found anything.

The approach I’m currently looking at involves grabbing the unprocessed HTML, extracting the script JSON with plenty of grep and sed, and running it through jq to get the unprocessed numbers in list form. I’ve not perfected the magical incantations needed but it’s almost there :grinning:

I’ve completed the script which extracts the Totals from the stats page. See the README for how to use.

With these numbers now available in this format they can then be used in a script for further analysis. I’m not aware of any API which provides these totals, so this approach seems like the only way to get them.

$ ./sitetotals
Getting totals for Site 68549
Aircraft reported: 126 1513 1481 1446 1549 1626 1465 1431 1435 1399 1425 1584 1568 1537 1443 1451 1452 1412 1577 1560 1539 1606 1494 1554 1534 1622 1583 1527 1421 1485 1420
Positions reported: 11158 272224 263651 269503 293014 294414 263112 253775 254256 247161 258050 290318 300565 275459 262911 258642 260305 241720 284723 282449 289531 269129 260909 281058 275313 290715 292221 293727 270390 259290 271587

Thanks for doing this work, and for your explanation!

For others, I thought this was really cool, but it didn’t do everything that I hoped it would. I made some changes that the author (for good reason) doesn’t want to merge into the main code, so I am offering my fork in case anyone has a similar use case.

Everything that I changed from the original is optional and defaulted to ‘off’. So out of the box it will operate in the same way as the original code.

I started out making a change because I wanted to use a comma as a delimiter rather than a space, and then realized that others might want to use some other character, so I made it a variable that users could edit.

Then I decided that it would be useful to write the data to a file that I could import straight into a spreadsheet, so I created an option to output to screen as originally written, or to a text file (added variable for file name), or to both. In either of those cases, it will append data to the existing file if it exists, or create on if it doesn’t. Finally, I thought it would be helpful to include the date row, so I added that in as well - but again, made it optional.

As far as I can tell, I have the defaults set so that out of the box the version with my edits works exactly the same as the original. There are just more options now.

I am thinking about running this monthly as a cron job so I also added an option to use a date/time-based unique file name.

I hope others find it as useful as I have!

3 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.