Skip to content

Instantly share code, notes, and snippets.

@airtower-luna
Created June 20, 2023 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save airtower-luna/4f371c7d8799632ba5b9ed855039a484 to your computer and use it in GitHub Desktop.
Save airtower-luna/4f371c7d8799632ba5b9ed855039a484 to your computer and use it in GitHub Desktop.
Mark GitHub notifications as read
import json
import os
import requests
from datetime import datetime, timezone
NOTIFICATIONS = 'https://api.github.com/notifications'
token = os.environ['GH_TOKEN']
s = requests.Session()
s.headers.update({
'Authorization': f'Bearer {token}',
'Accept': 'application/vnd.github+json'})
r = s.get(NOTIFICATIONS)
print(json.dumps(r.json(), indent=2))
now = datetime.now(timezone.utc)
print(now.isoformat(timespec='seconds'))
r = s.put(
NOTIFICATIONS,
json={
'last_read_at': now.isoformat(timespec='seconds'),
'read': True
})
print(r.status_code)
for k, v in r.headers.items():
print(f'{k}: {v}')
print(r.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment