schrockwell / hamsat_ex

Posting alerts for ham radio satellite activations
https://hams.at
11 stars 2 forks source link

Add an API endpoint to fetch activations #68

Closed schrockwell closed 6 months ago

schrockwell commented 7 months ago

Hey @magicbug, I see that Hams.at has made it into Cloudlog. Are you screen-scraping? Would you like me to add a proper JSON API endpoint?

magicbug commented 7 months ago

@schrockwell Please indeed I am scrapping the page!

I'm doing it so I get an output similar to

{
"date": "2024-01-29",
"start_time": "23:14:40",
"end_time": "00:31:45",
"callsign": "JR5JAQ/6",
"satellite": "GREENCUBE",
"gridsquare": "PM62/PM53",
"frequency": "435.310↑",
"mode": "Data",
"comment": "“#44 OITA Pref  (PM62) or(PM53)”",
"track_link": "https://hams.at/alerts/36aabf33-0932-49e5-9579-d93c185406aa"
},
{
"date": "2024-01-30",
"start_time": "03:27:15",
"end_time": "04:41:05",
"callsign": "JR5JAQ/6",
"satellite": "GREENCUBE",
"gridsquare": "PM62",
"frequency": "435.310↑",
"mode": "Data",
"comment": "“#44 OITA Pref  (PM62)”",
"track_link": "https://hams.at/alerts/f6204fec-b7b5-4b9b-8854-7eea0fd93ef9"
},
schrockwell commented 7 months ago

I have added the endpoint with two different return formats: a default format which resembles the underlying data and should be used by any new implementations, and a "cloudlog" format that aligns with your current implementation, to make the migration easier. Please try to move away from the "cloudlog" format and let me know when that is complete, so I can remove it.

The URLs are:

https://hams.at/api/alerts/upcoming
https://hams.at/api/alerts/upcoming?format=cloudlog

No authentication is required, and I haven't implemented rate limiting, so please play nice.

Here's an example response with ?format=cloudlog:

{
  "data": [
    {
      "callsign": "JR5JAQ/6",
      "comment": "#44 OITA Pref  (PM62) or(PM53)",
      "date": "2024-01-29",
      "end_time": "00:31:45",
      "frequency": "435.310↑",
      "gridsquare": "PM62/PM53",
      "mode": "Data",
      "satellite": "GREENCUBE",
      "start_time": "23:14:40",
      "track_link": "https://hams.at/alerts/36aabf33-0932-49e5-9579-d93c185406aa"
    },
    {
      "callsign": "JR5JAQ/6",
      "comment": "#44 OITA Pref  (PM62)",
      "date": "2024-01-30",
      "end_time": "04:41:05",
      "frequency": "435.310↑",
      "gridsquare": "PM62",
      "mode": "Data",
      "satellite": "GREENCUBE",
      "start_time": "03:27:15",
      "track_link": "https://hams.at/alerts/f6204fec-b7b5-4b9b-8854-7eea0fd93ef9"
    },
    // ...and so on...
  ]
}

and with the default format

{
  "data": [
    {
      "aos_at": "2024-01-29T23:14:40Z",
      "callsign": "JR5JAQ/6",
      "comment": "#44 OITA Pref  (PM62) or(PM53)",
      "grids": [
        "PM62",
        "PM53"
      ],
      "id": "36aabf33-0932-49e5-9579-d93c185406aa",
      "los_at": "2024-01-30T00:31:45Z",
      "mhz": 435.31,
      "mhz_direction": "up",
      "mode": "Data",
      "satellite": {
        "name": "GREENCUBE",
        "number": 53106
      },
      "url": "https://hams.at/alerts/36aabf33-0932-49e5-9579-d93c185406aa"
    },
    {
      "aos_at": "2024-01-30T03:27:15Z",
      "callsign": "JR5JAQ/6",
      "comment": "#44 OITA Pref  (PM62)",
      "grids": [
        "PM62"
      ],
      "id": "f6204fec-b7b5-4b9b-8854-7eea0fd93ef9",
      "los_at": "2024-01-30T04:41:05Z",
      "mhz": 435.31,
      "mhz_direction": "up",
      "mode": "Data",
      "satellite": {
        "name": "GREENCUBE",
        "number": 53106
      },
      "url": "https://hams.at/alerts/f6204fec-b7b5-4b9b-8854-7eea0fd93ef9"
    },
    ...and so on...
  ]
}
phl0 commented 6 months ago

I made a PR against https://github.com/magicbug/Cloudlog/. If this goes well we can drop the cloudlog specific format from the API.

magicbug commented 6 months ago

@schrockwell API now implimented thanks to @phl0 so you can remove the Cloudlog format and I'll switch off the scraping

schrockwell commented 6 months ago

All set. Thanks for the timeliness everyone!