diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..91a03f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +src/__pycache__ +*.swp +src/.token diff --git a/src/main.py b/src/main.py new file mode 100755 index 0000000..e5d03ce --- /dev/null +++ b/src/main.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +from twitch import TwitchClient + +def main(): + with open('.token', 'r') as reader: + twitch_token = reader.read().strip() + + client = TwitchClient(twitch_token) + print(client.raw_query('streams?first=20')) + +if __name__ == '__main__': + main() diff --git a/src/twitch.py b/src/twitch.py new file mode 100644 index 0000000..b860f98 --- /dev/null +++ b/src/twitch.py @@ -0,0 +1,12 @@ +import requests + +class TwitchClient: + + def __init__(self, token): + self.token = token + self.header = {'Client-ID': self.token} + self.urlbase = 'https://api.twitch.tv/helix/' + + def raw_query(self, q): + r = requests.get(self.urlbase+q, headers=self.header) + return r.text