Skip to content

feat: add v1 api client and webhook support - #35

Open
Zont1k wants to merge 10 commits into
top-gg-community:masterfrom
Zont1k:feat/v1-api
Open

feat: add v1 api client and webhook support#35
Zont1k wants to merge 10 commits into
top-gg-community:masterfrom
Zont1k:feat/v1-api

Conversation

@Zont1k

@Zont1k Zont1k commented Aug 16, 2026

Copy link
Copy Markdown

Adds the current top.gg v1 api to the library:

  • TopggV1Client for projects, metrics, announcements, slash commands and votes
  • Webhook signature verification (HMAC SHA-256) and event models
  • RFC 7807 error handling with Retry-After support
  • VoteCache: answer HasActiveVote from webhook-fed memory instead of hitting the api on every reward check
  • TopggAutoPoster: timer-based metrics posting for any project type
  • Discord.Net adapter that posts server and shard counts via the v1 api
  • Fixes the legacy v0 auth (raw token, no Bearer prefix) and the broken v0 Discord.Net SubmissionAdapter
  • Unit tests for signatures, deserialization, the v1 client, the vote cache and the autoposter

Version bumped to 1.7.0.

Zont1k added 10 commits August 16, 2026 22:30
Project, metrics, announcements, slash commands and votes for the new top.gg v1 api. Shared serializer options, loose string/number conversion and a robust ulong converter are included.
HMAC SHA-256 check against the x-topgg-signature header with an optional timestamp age limit, plus models for vote.create and webhook.test events.
v0 expects the raw token in the Authorization header. Removed the dead deserialization branch in GetAsync and flagged both clients as legacy.
The api field was never assigned, Stop() threw and there were two copies of DiscordNetDblUtils.
Posts server and shard count to PATCH /projects/@me/metrics on a timer, for regular and sharded clients.
Webhook signatures, event deserialization and the v1 client against a fake handler. Live v0 tests now skip unless BOT_ID and API_KEY are set.
Keeps recent votes in memory keyed by both top.gg and platform ids. Feed it from vote.create webhooks and check HasActiveVote without a single API call, so reward checks stay clear of the rate limits. Can be backfilled or refreshed from the v1 api.
Timer-based metrics posting for any project type, not just discord.net. Posts immediately on Start and then on a configurable interval (30 minutes by default), with Posted and PostFailed events.
GetAllVotesAsync crashed when the api returned a non-empty last page with no cursor.
Webhook ingestion, expiry, pruning and api sync for the cache; posting, failure and overlap handling for the autoposter. The sync test also catches the empty-cursor paging bug.
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.

1 participant