github-to-sqlite icon indicating copy to clipboard operation
github-to-sqlite copied to clipboard

Command for importing events

Open simonw opened this issue 6 years ago • 4 comments

Eg from https://api.github.com/users/simonw/events

Docs here: https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user

simonw avatar Nov 29 '19 21:11 simonw

I should build the command to persist ETags and obey their polling guidelines:

Events are optimized for polling with the "ETag" header. If no new events have been triggered, you will see a "304 Not Modified" response, and your current rate limit will be untouched. There is also an "X-Poll-Interval" header that specifies how often (in seconds) you are allowed to poll. In times of high server load, the time may increase. Please obey the header.

simonw avatar Nov 29 '19 21:11 simonw

Prototype:

pip install sqlite-utils paginate-json
paginate-json "https://api.github.com/users/simonw/events" | sqlite-utils insert /tmp/events.db events - --pk=id

simonw avatar Nov 30 '19 01:11 simonw

Since events include payloads with full object representations in them (for issues, repos and more) running this command every few minutes may be all it takes to keep a constant copy of everything updated in a very rate-limit friendly manner (thanks to the ETags).

simonw avatar Apr 14 '20 19:04 simonw