Skip to content

Add Twitch API to requests examples #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 21, 2022
Merged

Add Twitch API to requests examples #121

merged 9 commits into from
Nov 21, 2022

Conversation

DJDevon3
Copy link
Contributor

Uses real 0auth bearer token. Developer account & client id (bot app) required.

For FoamyGuy, thank you for the help.
Because searching for a link to the place where you're supposed to create the 0auth app is sometimes like trying to find a needle in a haystack.
No token required to get your own followers, publicly accessible.
@dhalbert dhalbert requested a review from a team November 17, 2022 14:08
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding more of these examples @DJDevon3! Appreciate you taking on the gnarlier twitch API with OAuth. I was poking around in their API docs and there are some neat integrations that are possible and now much easier to achieve with the groundwork you laid.

I tested out both of these successfully on Feather ESP32-S2 TFT. One, minor request on the Mastadon one to make it easier to swap between different server instances. Looking good to me beyond that.


# Publicly available data no header required
MAST_SOURCE = (
"https://mastodon.cloud/api/v1/accounts/" + Mastodon_UserID + "/statuses?limit=1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to make the server portion of this URL a variable as well.

Also perhaps consider string formatting instead of concatenating with plus signs. In this case there is no functional difference, but sometimes plus signs result in unwanted math addition, whereas string substitution / formatting is the actual intention.

Server_Name = "cloud"

# ...

f"https://mastodon.{Server_Name}/api/v1/accounts/{Mastodon_UserID}/statuses?limit=1"

Since the service is designed to have different servers this will make it easier for people to fill in the one they are using. I tested on "social" server.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops nice catch. Yeah that's the server I use. Hardcoded something during development and promptly ignored it forever. Will do.

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks again @DJDevon3

@FoamyGuy FoamyGuy merged commit c82bf4c into adafruit:main Nov 21, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 22, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_MCP4728 to 1.3.4 from 1.3.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_MCP4728#14 from tcfranks/main
  > Update .pylintrc for v2.15.5
  > Fix release CI files
  > Update pylint to 2.15.5
  > Updated pylint version to 2.13.0
  > Switching to composite actions

Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel to 6.3.7 from 6.3.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel#143 from kattni/rainbowio-simpletest
  > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel#141 from tekktrik/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.12.11 from 1.12.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#121 from DJDevon3/main
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