SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
Developer Infrastructure Team: API & Identity
surviv.io fan
J.N Vollmer

Director of Engineering
Responding to Feedback:
What’s New in the Twitch API
TwitchCon 2018 San Jose, California
What’s the New
Twitch API Again?
REST APIs
Webhooks
Identity
TwitchCon 2018 San Jose, California
Top consumers are Extensions and
streamer tools
778%
Growth in usage
Yr-on-Yr
83%
Of the new API traffic
Is Extensions
99.995%
API Uptime
Key Facts About the
New Twitch API in 2018
99.949%
Webhooks Uptime
TwitchCon 2018 San Jose, California
-Consume, create, and update
relevant Twitch-related data
-Build engaging experiences for
Twitch streamers and viewers
-Consistent design across endpoints
-Bulk capabilities where applicable
-Transparent
#1.
/helix REST APIs
WHAT IS THE NEW TWITCH API?
4 Tenets of the New Twitch API
Reliability
Consistency
Simplicity
Transparency
TwitchCon 2018 San Jose, California
- Stream markers
- Game analytics
- Extension Analytics
- Bits leaderboard
- Clips
- User Extensions
Made for
Tools Dev
Games Dev
Extensions Dev
#1.
/helix REST APIs
WHAT’S NEW IN 2018
TwitchCon 2018 San Jose, California
What’s a webhook?
- Stop calling us, we’ll call you
- A Reverse API: a web callback or http push
API
How is this related to standard REST APIs?
- Consistent data schema: identical to
the /helix corresponding APIs
- Built on W3C Websub standard
#2.
Webhooks Benefits
Real-time Events
Cost Savings
No More Polling
WHAT IS THE NEW TWITCH API?
TwitchCon 2018 San Jose, California
new follower?
Your App
Server
Nope
new follower?
Nope
new follower?
Nope
new follower?
You have a new
follower
Twitch
REST Polling
#2 

Webhooks
WHAT’S THE NEW TWITCH API?
TwitchCon 2018 San Jose, California
#2 

Webhooks
WHAT’S THE NEW TWITCH API?
Subscribe to
new followers
Server
Ok
Confirm
subscription?
Ok
new follower
Webhook Flows
new follower
new follower
Twitch
TwitchCon 2018 San Jose, California
- Stream Changed (initially stream
Up/Down)
- User Changed
- Game Analytics
- Extension Analytics
- Webhooks Subscription
Management API
WHAT’S NEW IN 2018?
#2.
Webhooks
TwitchCon 2018 San Jose, California
- Who can access what resources,
with what permissions
- In the API context, our solution for
authenticating and authorizing API
calls
- OAuth 2 Standard
#3.
Identity
WHAT IS THE NEW TWITCH API?
TwitchCon 2018 San Jose, California
- Many behind-the-scenes security
and performance improvements
- Revamped app authorization screen
Benefits:
- Security
- Performance
- Security!
#3.
Identity
WHAT’S NEW IN 2018?
TwitchCon 2018 San Jose, California
- Quick and frictionless onboarding:
build a new test integration from
scratch in minutes
- Limits on what each integration can
do by default
• For the greater good of the
developer community
• To protect users’ private data
- Protection and support to enable
high-traffic integrations
Overall
WHAT’S THE NEW TWITCH API?
TwitchCon 2018 San Jose, California
What Do You
(Twitch API Developers)
Want?
Your feedback and what we’re
doing about it
TwitchCon 2018 San Jose, California
“We’ve had three big ideas […]
that we’ve stuck with for 18 years,
and they’re the reason we’re
successful: Put the customer first.
Invent. And be patient.”
TwitchCon 2018 San Jose, California
“We’ve had three big ideas […]
that we’ve stuck with for 18
years, and they’re the reason
we’re successful: Put the
customer first. Invent. And be
patient.”
TwitchCon 2018 San Jose, California
Collect Feedback
Identify
Challenges
Trade Offs &
Solutions
Design
Philosophy
Steering
Committee
How Twitch API

Puts the
Customer First
TwitchCon 2018 San Jose, California
You want to get relevant data in as few
calls as possible.
- userID field in API responses is generally
“not useful enough”
- API is too chatty
- Worse for webhooks: a push should not
need subsequent pulls
- “90% of our calls to the new Twitch API
are to translate userIDs to userNames.”
Data
Fragmentation
PROBLEM #1
TwitchCon 2018 San Jose, California
Instead of just returning the userID to
represent a user in API responses and
webhooks, we are adding the
userName
A more pragmatic and flexible approach
Denormalization
of Key Field
SOLUTION #1
BEFORE: A USER == { USERID }
AFTER: A USER == { USERID, USERNAME }
Lower the number of calls
TwitchCon 2018 San Jose, California
Restrictive
Rate Limiting
PROBLEM #2
- Existing rate limiting mechanism is
client-ID based
- Good intention: protect everyone and
enable scaling
BUT:
- Prevents your app from being popular
- Large spike in viewership will bring the
number of calls over the limit and make
an app unusable
- Compounded by problem #1 (need for
additional API requests)
TwitchCon 2018 San Jose, California
Token bucket algorithm: burst
friendly by design
Variable point value per endpoint
Supports continous growth and burst
Smart Rate
Limiting
SOLUTION #2
Your limit varies with user generated traffic
Based on:
- clientID+userID for calls that provide an
OAuth token
- IP for calls otherwise
TwitchCon 2018 San Jose, California
Subscriptions API
Endpoint
PROBLEM #1
- Exists in the legacy v5 API
BUT:
- Unreliable; some fields are inconsistent
- Suboptimal design; legacy API is too
permissive
TwitchCon 2018 San Jose, California
New Subscriptions
API Endpoint
SOLUTION #3
Enables two use cases:
- Get list of subscribers for a channel
- Confirm whether a viewer is
subscribed to a given channel
BONUS:
-Webhook
BENEFITS
- Safer
- Consistent
- Real-time data push
TwitchCon 2018 San Jose, California
What Can You
Build?
A few ideas…
TwitchCon 2018 San Jose, California
Use Case:
Stream Markers
ELGATO STREAM DECK
Announcement: https://discuss.dev.twitch.tv/t/introducing-the-stream-markers-api/
- Programmable keypad with 15 LCD
- Specifically built for streamers; very
popular
- First product of its kind that replaces
random keybindings
Stream Markers API enables a
“marker button”
TwitchCon 2018 San Jose, California
Use Case:
Stream Markers
TwitchCon 2018 San Jose, California
“The Create Stream Marker API is
perfect for our use case.
I quickly implemented it in Stream Deck
and this works great: […] the Stream
Marker automagically appears in Twitch.
- Alexandre Colucci, Tech Lead @elgato
TwitchCon 2018 San Jose, California
“New Follower”
Webhook
STREAMLABS WIDGETS
- Push real-time on screen
notifications to viewers when a
streamer gets a new follower
- Leads to streamer and viewer
excitement and engagement with
viewers
- Before webhooks, the use case could
only be accomplished with polling,
with delays
TwitchCon 2018 San Jose, California
STREAMLABS
“New follower”
webhook
TwitchCon 2018 San Jose, California
How Do I
Get Started?
A quick tutorial/refresher…
TwitchCon 2018 San Jose, California
Sign into Twitch
Dev Site
GETTING STARTED
HTTP://DEV.TWITCH.TV
TwitchCon 2018 San Jose, California
Create an Extension
or App
GETTING STARTED
- Apps are a simple basic
construct to make API calls
- Extensions are more
sophisticated, but based on the
same core concepts. Use the
Extensions Dev Rig on Github!
- You will receive a client ID and a
client Secret
- Pass the Client-ID in a header
- Get the data
Pros:
- Simple
Cons:
- Low rate limit
Call an
‘Anonymous’
Endpoint
BASIC USE CASE
TwitchCon 2018 San Jose, California
Create and Use a
Bearer Token
REGULAR USE CASE
- Three types of tokens
- Three types of flows
https://dev.twitch.tv/docs/
authentication/#getting-tokens
- Simplest combination: OAuth user
access token with implicit grant
- Request only the scopes you need
TwitchCon 2018 San Jose, California
OAuth 2 Implicit
Grant Flow
Your App
(Client)
Twitch Server
Authorization
Endpoint
(id.twitch.tv)
#1
Authentication/
Authorization
Request
Twitch User
#2
Auth Request
Twitch Server
Authorization
Endpoint
(id.twitch.tv)
#3
Auth Granted
Your App
(Client)
#4
Access Token
OAuth user access token with
implicit grant Simple
How to Create a
Bearer Token
curl -X GET 'https://id.twitch.tv/oauth2/authorize?
response_type=token&client_id=uo6dggojyb8d6soh92zknwmi
ej1q2&redirect_uri=http://
localhost&scope=viewing_activity_read&state=c3ab8aa609
a11e793ae92361f002671'
//Redirects to”:
https://
localhost#access_token=0123456789abcdefghijABCDEFGHIJ
&scope=viewing_activity_read
&state=c3ab8aa609ea11e793ae92361f002671
&token_type=bearer
1

2

3

4

5

6

7

8

9

1
0

1
1

How to Create a Bearer Token
Calling the Users API to Retrieve Details of a Given User
curl -H 'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y' 
-X GET 'https://api.twitch.tv/helix/users?id=44322889'
{
"data": [{
"id": "44322889",
"login": "dallas",
"display_name": "dallas",
"type": "staff",
"broadcaster_type": "",
"description": "Just a gamer playing games and chatting. :)",
"profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/d.png",
"offline_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/d.png",
"view_count": 191836881,
"email": "login@provider.com"
}]
}
1

2

3

4

5

6

7

8

9

10

11

12
13
14
15
16
17
18
That’s it!
You are ready to roll
Questions?
See you on https://dev.twitch.tv
Thank you!

Mais conteúdo relacionado

Mais procurados

Business Impact (Nordic APIS April 2014)
Business Impact (Nordic APIS April 2014)Business Impact (Nordic APIS April 2014)
Business Impact (Nordic APIS April 2014)
Nordic APIs
 

Mais procurados (20)

apidays LIVE LONDON - Architecting Scalable Software Platforms for IoT Applic...
apidays LIVE LONDON - Architecting Scalable Software Platforms for IoT Applic...apidays LIVE LONDON - Architecting Scalable Software Platforms for IoT Applic...
apidays LIVE LONDON - Architecting Scalable Software Platforms for IoT Applic...
 
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
apidays LIVE LONDON - Protecting financial-grade APIs - Getting the right API...
 
Building Extensions With You
Building Extensions With YouBuilding Extensions With You
Building Extensions With You
 
#ATAGTR2020 Presentation - Redefining DevOps for seamless performance testing
#ATAGTR2020 Presentation - Redefining DevOps for seamless performance testing#ATAGTR2020 Presentation - Redefining DevOps for seamless performance testing
#ATAGTR2020 Presentation - Redefining DevOps for seamless performance testing
 
History and Future of the Netflix API - Mashery Evolution of Distribution
History and Future of the Netflix API - Mashery Evolution of DistributionHistory and Future of the Netflix API - Mashery Evolution of Distribution
History and Future of the Netflix API - Mashery Evolution of Distribution
 
Business Impact (Nordic APIS April 2014)
Business Impact (Nordic APIS April 2014)Business Impact (Nordic APIS April 2014)
Business Impact (Nordic APIS April 2014)
 
API Strategy Introduction
API Strategy IntroductionAPI Strategy Introduction
API Strategy Introduction
 
Drones, Phones & Pwns the Promise & Dangers of IoT APIs: Use APIs to Securely...
Drones, Phones & Pwns the Promise & Dangers of IoT APIs: Use APIs to Securely...Drones, Phones & Pwns the Promise & Dangers of IoT APIs: Use APIs to Securely...
Drones, Phones & Pwns the Promise & Dangers of IoT APIs: Use APIs to Securely...
 
#ATAGTR2020 Presentation - The Splunk Integration for Futuristic NFT in DevOp...
#ATAGTR2020 Presentation - The Splunk Integration for Futuristic NFT in DevOp...#ATAGTR2020 Presentation - The Splunk Integration for Futuristic NFT in DevOp...
#ATAGTR2020 Presentation - The Splunk Integration for Futuristic NFT in DevOp...
 
OAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST ServicesOAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST Services
 
State of the API: Insights Into the Future of APIs
State of the API: Insights Into the Future of APIsState of the API: Insights Into the Future of APIs
State of the API: Insights Into the Future of APIs
 
Twitch for Game Developers
Twitch for Game DevelopersTwitch for Game Developers
Twitch for Game Developers
 
The Swisscom APi journey
The Swisscom APi journeyThe Swisscom APi journey
The Swisscom APi journey
 
Api architectures for the modern enterprise
Api architectures for the modern enterpriseApi architectures for the modern enterprise
Api architectures for the modern enterprise
 
Adapt or Die Sydney - API Security
Adapt or Die Sydney - API SecurityAdapt or Die Sydney - API Security
Adapt or Die Sydney - API Security
 
Enabling the Multi-Device Universe
Enabling the Multi-Device UniverseEnabling the Multi-Device Universe
Enabling the Multi-Device Universe
 
Hello SMS!
Hello SMS!Hello SMS!
Hello SMS!
 
Twitch Extensions 101
Twitch Extensions 101Twitch Extensions 101
Twitch Extensions 101
 
We Built This City - Apigee Edge Architecture
We Built This City - Apigee Edge ArchitectureWe Built This City - Apigee Edge Architecture
We Built This City - Apigee Edge Architecture
 
Common Security API Issues and How to Mitigate Them Using Postman
Common Security API Issues and How to Mitigate Them Using PostmanCommon Security API Issues and How to Mitigate Them Using Postman
Common Security API Issues and How to Mitigate Them Using Postman
 

Semelhante a Responding to Feedback: What's New in the Twitch API

Semelhante a Responding to Feedback: What's New in the Twitch API (20)

APIdays Singapore 2019 - Business of APIs: From Integration to Monetisation, ...
APIdays Singapore 2019 - Business of APIs: From Integration to Monetisation, ...APIdays Singapore 2019 - Business of APIs: From Integration to Monetisation, ...
APIdays Singapore 2019 - Business of APIs: From Integration to Monetisation, ...
 
Perth Meetup August 2021
Perth Meetup August 2021Perth Meetup August 2021
Perth Meetup August 2021
 
Apigee Edge Overview and Roadmap
Apigee Edge Overview and RoadmapApigee Edge Overview and Roadmap
Apigee Edge Overview and Roadmap
 
João Emilio Santos Bento da Silva - Estratégia de APIs
João Emilio Santos Bento da Silva - Estratégia de APIsJoão Emilio Santos Bento da Silva - Estratégia de APIs
João Emilio Santos Bento da Silva - Estratégia de APIs
 
RefCard API Architecture Strategy
RefCard API Architecture StrategyRefCard API Architecture Strategy
RefCard API Architecture Strategy
 
Open Banking & Open Insurance
Open Banking & Open InsuranceOpen Banking & Open Insurance
Open Banking & Open Insurance
 
Twitter API 2.0
Twitter API 2.0Twitter API 2.0
Twitter API 2.0
 
Crystal clear service interfaces w/ Swagger/OpenAPI
Crystal clear service interfaces w/ Swagger/OpenAPICrystal clear service interfaces w/ Swagger/OpenAPI
Crystal clear service interfaces w/ Swagger/OpenAPI
 
[WSO2 Summit Americas 2020] Having the Best Technology Isn’t Everything
[WSO2 Summit Americas 2020] Having the Best Technology Isn’t Everything[WSO2 Summit Americas 2020] Having the Best Technology Isn’t Everything
[WSO2 Summit Americas 2020] Having the Best Technology Isn’t Everything
 
Z101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apisZ101666 best practices for delivering hybrid cloud capability with apis
Z101666 best practices for delivering hybrid cloud capability with apis
 
Technology Primer: Customize CA Application Performance Management With Tip...
Technology Primer: Customize CA Application Performance Management  With Tip...Technology Primer: Customize CA Application Performance Management  With Tip...
Technology Primer: Customize CA Application Performance Management With Tip...
 
Growth Hacking APIs (Nordic APIs conference 2014)
Growth Hacking APIs (Nordic APIs conference 2014)Growth Hacking APIs (Nordic APIs conference 2014)
Growth Hacking APIs (Nordic APIs conference 2014)
 
Maintaining the Front Door to Netflix
Maintaining the Front Door to NetflixMaintaining the Front Door to Netflix
Maintaining the Front Door to Netflix
 
Tech Talk: Monitor the Performance of APIs Across the Application Lifecycle
Tech Talk: Monitor the Performance of APIs Across the Application LifecycleTech Talk: Monitor the Performance of APIs Across the Application Lifecycle
Tech Talk: Monitor the Performance of APIs Across the Application Lifecycle
 
API Frenzy: API Strategy 101
API Frenzy: API Strategy 101API Frenzy: API Strategy 101
API Frenzy: API Strategy 101
 
Accelerating API Development With OpenAPI and Serverless
Accelerating API Development With OpenAPI and ServerlessAccelerating API Development With OpenAPI and Serverless
Accelerating API Development With OpenAPI and Serverless
 
6 Best Practices that Make a Great API .pdf
6 Best Practices that Make a Great API .pdf6 Best Practices that Make a Great API .pdf
6 Best Practices that Make a Great API .pdf
 
APIs as a Product Strategy
APIs as a Product StrategyAPIs as a Product Strategy
APIs as a Product Strategy
 
Madrid meetup #8 acm intro
Madrid meetup #8   acm introMadrid meetup #8   acm intro
Madrid meetup #8 acm intro
 
Under the Hood of the New Twitch API - TwitchCon Developer Day 2017
Under the Hood of the New Twitch API - TwitchCon Developer Day 2017Under the Hood of the New Twitch API - TwitchCon Developer Day 2017
Under the Hood of the New Twitch API - TwitchCon Developer Day 2017
 

Mais de Twitch Developers

Mais de Twitch Developers (20)

Embracing the Hobbyist Persona
Embracing the Hobbyist PersonaEmbracing the Hobbyist Persona
Embracing the Hobbyist Persona
 
Using Insights to Build Better Products and Grow on Twitch
Using Insights to Build Better Products and Grow on TwitchUsing Insights to Build Better Products and Grow on Twitch
Using Insights to Build Better Products and Grow on Twitch
 
TwitchCon Developer Day Keynote
TwitchCon Developer Day KeynoteTwitchCon Developer Day Keynote
TwitchCon Developer Day Keynote
 
Rapid Prototyping Twitch Extensions: Five Lessons Learned
Rapid Prototyping Twitch Extensions: Five Lessons LearnedRapid Prototyping Twitch Extensions: Five Lessons Learned
Rapid Prototyping Twitch Extensions: Five Lessons Learned
 
Monetize Your Extension a Bit at a Time
Monetize Your Extension a Bit at a TimeMonetize Your Extension a Bit at a Time
Monetize Your Extension a Bit at a Time
 
Twitch Extension Review Process: The Missing Manual
Twitch Extension Review Process: The Missing ManualTwitch Extension Review Process: The Missing Manual
Twitch Extension Review Process: The Missing Manual
 
Making Your Game a Success With Twitch
Making Your Game a Success With TwitchMaking Your Game a Success With Twitch
Making Your Game a Success With Twitch
 
Extension Design Patterns for Twitch Scale
Extension Design Patterns for Twitch ScaleExtension Design Patterns for Twitch Scale
Extension Design Patterns for Twitch Scale
 
Get Your Extension Discovered
Get Your Extension DiscoveredGet Your Extension Discovered
Get Your Extension Discovered
 
Bots Bots Bots: Building Chatbots
Bots Bots Bots: Building ChatbotsBots Bots Bots: Building Chatbots
Bots Bots Bots: Building Chatbots
 
Twitch Developer Tour
Twitch Developer Tour Twitch Developer Tour
Twitch Developer Tour
 
How Streaming is Changing the Way We Play
How Streaming is Changing the Way We PlayHow Streaming is Changing the Way We Play
How Streaming is Changing the Way We Play
 
Twitch Insights: Player Research and Interaction
Twitch Insights: Player Research and InteractionTwitch Insights: Player Research and Interaction
Twitch Insights: Player Research and Interaction
 
Twitch + Games
Twitch + GamesTwitch + Games
Twitch + Games
 
Using Twitch Drops to Promote Viewer Engagement
Using Twitch Drops to Promote Viewer Engagement Using Twitch Drops to Promote Viewer Engagement
Using Twitch Drops to Promote Viewer Engagement
 
Twitch Extensions: Live Apps for Live Streams
Twitch Extensions: Live Apps for Live StreamsTwitch Extensions: Live Apps for Live Streams
Twitch Extensions: Live Apps for Live Streams
 
Making Twitch Interactive with Twitch Extensions
Making Twitch Interactive with Twitch ExtensionsMaking Twitch Interactive with Twitch Extensions
Making Twitch Interactive with Twitch Extensions
 
Improving Game Performance and Streaming with Twitch Insights
Improving Game Performance and Streaming with Twitch Insights Improving Game Performance and Streaming with Twitch Insights
Improving Game Performance and Streaming with Twitch Insights
 
Engaging Your Community with Twitch
Engaging Your Community with TwitchEngaging Your Community with Twitch
Engaging Your Community with Twitch
 
Empowering Extensions with Game APIs
Empowering Extensions with Game APIsEmpowering Extensions with Game APIs
Empowering Extensions with Game APIs
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Responding to Feedback: What's New in the Twitch API

  • 1. Developer Infrastructure Team: API & Identity surviv.io fan J.N Vollmer
 Director of Engineering
  • 2. Responding to Feedback: What’s New in the Twitch API
  • 3. TwitchCon 2018 San Jose, California What’s the New Twitch API Again? REST APIs Webhooks Identity
  • 4. TwitchCon 2018 San Jose, California Top consumers are Extensions and streamer tools 778% Growth in usage Yr-on-Yr 83% Of the new API traffic Is Extensions 99.995% API Uptime Key Facts About the New Twitch API in 2018 99.949% Webhooks Uptime
  • 5. TwitchCon 2018 San Jose, California -Consume, create, and update relevant Twitch-related data -Build engaging experiences for Twitch streamers and viewers -Consistent design across endpoints -Bulk capabilities where applicable -Transparent #1. /helix REST APIs WHAT IS THE NEW TWITCH API? 4 Tenets of the New Twitch API Reliability Consistency Simplicity Transparency
  • 6. TwitchCon 2018 San Jose, California - Stream markers - Game analytics - Extension Analytics - Bits leaderboard - Clips - User Extensions Made for Tools Dev Games Dev Extensions Dev #1. /helix REST APIs WHAT’S NEW IN 2018
  • 7. TwitchCon 2018 San Jose, California What’s a webhook? - Stop calling us, we’ll call you - A Reverse API: a web callback or http push API How is this related to standard REST APIs? - Consistent data schema: identical to the /helix corresponding APIs - Built on W3C Websub standard #2. Webhooks Benefits Real-time Events Cost Savings No More Polling WHAT IS THE NEW TWITCH API?
  • 8. TwitchCon 2018 San Jose, California new follower? Your App Server Nope new follower? Nope new follower? Nope new follower? You have a new follower Twitch REST Polling #2 
 Webhooks WHAT’S THE NEW TWITCH API?
  • 9. TwitchCon 2018 San Jose, California #2 
 Webhooks WHAT’S THE NEW TWITCH API? Subscribe to new followers Server Ok Confirm subscription? Ok new follower Webhook Flows new follower new follower Twitch
  • 10. TwitchCon 2018 San Jose, California - Stream Changed (initially stream Up/Down) - User Changed - Game Analytics - Extension Analytics - Webhooks Subscription Management API WHAT’S NEW IN 2018? #2. Webhooks
  • 11. TwitchCon 2018 San Jose, California - Who can access what resources, with what permissions - In the API context, our solution for authenticating and authorizing API calls - OAuth 2 Standard #3. Identity WHAT IS THE NEW TWITCH API?
  • 12. TwitchCon 2018 San Jose, California - Many behind-the-scenes security and performance improvements - Revamped app authorization screen Benefits: - Security - Performance - Security! #3. Identity WHAT’S NEW IN 2018?
  • 13. TwitchCon 2018 San Jose, California - Quick and frictionless onboarding: build a new test integration from scratch in minutes - Limits on what each integration can do by default • For the greater good of the developer community • To protect users’ private data - Protection and support to enable high-traffic integrations Overall WHAT’S THE NEW TWITCH API?
  • 14. TwitchCon 2018 San Jose, California What Do You (Twitch API Developers) Want? Your feedback and what we’re doing about it
  • 15. TwitchCon 2018 San Jose, California “We’ve had three big ideas […] that we’ve stuck with for 18 years, and they’re the reason we’re successful: Put the customer first. Invent. And be patient.”
  • 16. TwitchCon 2018 San Jose, California “We’ve had three big ideas […] that we’ve stuck with for 18 years, and they’re the reason we’re successful: Put the customer first. Invent. And be patient.”
  • 17. TwitchCon 2018 San Jose, California Collect Feedback Identify Challenges Trade Offs & Solutions Design Philosophy Steering Committee How Twitch API
 Puts the Customer First
  • 18. TwitchCon 2018 San Jose, California You want to get relevant data in as few calls as possible. - userID field in API responses is generally “not useful enough” - API is too chatty - Worse for webhooks: a push should not need subsequent pulls - “90% of our calls to the new Twitch API are to translate userIDs to userNames.” Data Fragmentation PROBLEM #1
  • 19. TwitchCon 2018 San Jose, California Instead of just returning the userID to represent a user in API responses and webhooks, we are adding the userName A more pragmatic and flexible approach Denormalization of Key Field SOLUTION #1 BEFORE: A USER == { USERID } AFTER: A USER == { USERID, USERNAME } Lower the number of calls
  • 20. TwitchCon 2018 San Jose, California Restrictive Rate Limiting PROBLEM #2 - Existing rate limiting mechanism is client-ID based - Good intention: protect everyone and enable scaling BUT: - Prevents your app from being popular - Large spike in viewership will bring the number of calls over the limit and make an app unusable - Compounded by problem #1 (need for additional API requests)
  • 21. TwitchCon 2018 San Jose, California Token bucket algorithm: burst friendly by design Variable point value per endpoint Supports continous growth and burst Smart Rate Limiting SOLUTION #2 Your limit varies with user generated traffic Based on: - clientID+userID for calls that provide an OAuth token - IP for calls otherwise
  • 22. TwitchCon 2018 San Jose, California Subscriptions API Endpoint PROBLEM #1 - Exists in the legacy v5 API BUT: - Unreliable; some fields are inconsistent - Suboptimal design; legacy API is too permissive
  • 23. TwitchCon 2018 San Jose, California New Subscriptions API Endpoint SOLUTION #3 Enables two use cases: - Get list of subscribers for a channel - Confirm whether a viewer is subscribed to a given channel BONUS: -Webhook BENEFITS - Safer - Consistent - Real-time data push
  • 24. TwitchCon 2018 San Jose, California What Can You Build? A few ideas…
  • 25. TwitchCon 2018 San Jose, California Use Case: Stream Markers ELGATO STREAM DECK Announcement: https://discuss.dev.twitch.tv/t/introducing-the-stream-markers-api/ - Programmable keypad with 15 LCD - Specifically built for streamers; very popular - First product of its kind that replaces random keybindings Stream Markers API enables a “marker button”
  • 26. TwitchCon 2018 San Jose, California Use Case: Stream Markers
  • 27. TwitchCon 2018 San Jose, California “The Create Stream Marker API is perfect for our use case. I quickly implemented it in Stream Deck and this works great: […] the Stream Marker automagically appears in Twitch. - Alexandre Colucci, Tech Lead @elgato
  • 28. TwitchCon 2018 San Jose, California “New Follower” Webhook STREAMLABS WIDGETS - Push real-time on screen notifications to viewers when a streamer gets a new follower - Leads to streamer and viewer excitement and engagement with viewers - Before webhooks, the use case could only be accomplished with polling, with delays
  • 29. TwitchCon 2018 San Jose, California STREAMLABS “New follower” webhook
  • 30. TwitchCon 2018 San Jose, California How Do I Get Started? A quick tutorial/refresher…
  • 31. TwitchCon 2018 San Jose, California Sign into Twitch Dev Site GETTING STARTED HTTP://DEV.TWITCH.TV
  • 32. TwitchCon 2018 San Jose, California Create an Extension or App GETTING STARTED - Apps are a simple basic construct to make API calls - Extensions are more sophisticated, but based on the same core concepts. Use the Extensions Dev Rig on Github! - You will receive a client ID and a client Secret
  • 33. - Pass the Client-ID in a header - Get the data Pros: - Simple Cons: - Low rate limit Call an ‘Anonymous’ Endpoint BASIC USE CASE
  • 34. TwitchCon 2018 San Jose, California Create and Use a Bearer Token REGULAR USE CASE - Three types of tokens - Three types of flows https://dev.twitch.tv/docs/ authentication/#getting-tokens - Simplest combination: OAuth user access token with implicit grant - Request only the scopes you need
  • 35. TwitchCon 2018 San Jose, California OAuth 2 Implicit Grant Flow Your App (Client) Twitch Server Authorization Endpoint (id.twitch.tv) #1 Authentication/ Authorization Request Twitch User #2 Auth Request Twitch Server Authorization Endpoint (id.twitch.tv) #3 Auth Granted Your App (Client) #4 Access Token
  • 36. OAuth user access token with implicit grant Simple How to Create a Bearer Token curl -X GET 'https://id.twitch.tv/oauth2/authorize? response_type=token&client_id=uo6dggojyb8d6soh92zknwmi ej1q2&redirect_uri=http:// localhost&scope=viewing_activity_read&state=c3ab8aa609 a11e793ae92361f002671' //Redirects to”: https:// localhost#access_token=0123456789abcdefghijABCDEFGHIJ &scope=viewing_activity_read &state=c3ab8aa609ea11e793ae92361f002671 &token_type=bearer 1
 2
 3
 4
 5
 6
 7
 8
 9
 1 0
 1 1

  • 37. How to Create a Bearer Token Calling the Users API to Retrieve Details of a Given User curl -H 'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y' -X GET 'https://api.twitch.tv/helix/users?id=44322889' { "data": [{ "id": "44322889", "login": "dallas", "display_name": "dallas", "type": "staff", "broadcaster_type": "", "description": "Just a gamer playing games and chatting. :)", "profile_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/d.png", "offline_image_url": "https://static-cdn.jtvnw.net/jtv_user_pictures/d.png", "view_count": 191836881, "email": "login@provider.com" }] } 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12 13 14 15 16 17 18
  • 38. That’s it! You are ready to roll
  • 40. See you on https://dev.twitch.tv Thank you!