Skip to content

Add api/get_contacts_adif endpoint for incremental ADIF export - #3485

Open
finlstrm wants to merge 7 commits into
magicbug:devfrom
finlstrm:get_contacts_adif
Open

finlstrm wants to merge 7 commits into
magicbug:devfrom
finlstrm:get_contacts_adif

Conversation

@finlstrm

Copy link
Copy Markdown

Add api/get_contacts_adif endpoint for incremental ADIF export

Summary

Adds POST /api/get_contacts_adif, which lets an API client download the QSOs of one station location as ADIF using a QSO-ID cursor, so new contacts can be synced without re-downloading the whole logbook.

POST /index.php/api/get_contacts_adif
Content-Type: application/json

{"key": "YOUR_API_KEY", "station_id": 1, "fetchfromid": 0, "limit": 5000}

The response includes exported_qsos, lastfetchedid (pass it as fetchfromid next time), has_more and the adif string. limit defaults to 5000, maximum 10000.

Security

  • Uses the existing API key model: active key, r or rw rights, with an owning user.
  • station_id must be a station location owned by the key's user. The SQL is scoped by station and owner, so changing the ID or cursor can't reach another user's data. Nonexistent and unauthorized stations return the same 403.
  • Strict JSON and integer validation, and responses are always pure JSON.

Changes

  • Api.php: new get_contacts_adif() method.
  • Adif_data.php: new scoped query.
  • AdifHelper.php: new getAdifHeader().
  • New Adif_export_request.php for request validation.
  • New docs: docs/api_get_contacts_adif.md.

No schema changes or migrations, and no existing endpoints are modified.

Tests

No unit tests have been included or written.
Active testing live against my own Cloudlog installation at v2.8.19 with no errors.

Inspiration

Developing my own unofficial desktop companion to Cloudlog, kc1mjp/cloudlog-desktop, I wanted to pull down my logbooks from Cloudlog via the API. Among other things, this allows an operator to see worked-before information using an offline local QSO cache. This would be great for the POTA/SOTA operator.

Other than the clunky method I was already using the Backup function of Cloudlog kc1mjp-tools/cloudlogBackup.sh and requires server-side cleanup of backups, I discovered there was still no proper API endpoint pulling down QSOs.

What I did find was Wavelog had implemented just the endpoint I was looking for, but I've already standardized on Cloudlog. So to scratch another itch, I implemented it here for Cloudlog.

Limitations

The cursor only detects newly added QSOs, not edits or deletions, though re-download of entire logbook is supported. Stations shared through a shared logbook are not exportable.

@finlstrm

Copy link
Copy Markdown
Author

Discussion in #3484

@finlstrm
finlstrm marked this pull request as ready for review October 29, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants