SlideShare a Scribd company logo
Do More, Faster
The Twitter Streaming API
1. Create a HTTP Request

GET /1/statuses/sample.json HTTP/1.1
Authorization: OAuth realm="",oauth_no...
Host: stream.twitter.com
Accept: */*


             Sign it with OAuth
2. Handle the response
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(6.1.25)

{"in_reply_to_status_id_str":null,"geo":n
ull,"text":"Hey fat boyyyyy!!...


   What’s missing? No Content-Length header!
HTTP Libraries won’t know when to stop consuming
3. Keep handling it

• Twitter will keep sending you JSON chunks
  until you kill the connection
• Normal HTTP libraries make this awkward
• Try non-blocking / event-based I/O
The Streaming API lets
  you do cool stuff
• Sample the firehose, free ~1%
• Get interesting subsets of all tweets
 • By filtering, can get all tweets on a topic
• Interact in near-realtime
• Process more efficiently
Also...


• User Streams
• Site Streams
At Conversocial, we built a way to search twitter
            on behalf of our clients.




There’s a stream client that receives tweets from the
                    Streaming API
We monitor the stream client from a separate thread
We still have to poll the REST API to cover gaps between
                        connections
Need to disconnect stream client from processing tasks.
               We do this via a queue.
Searches have to be matched back to the terms that
    produced them - the stream is multiplexed.
Thanks for listening!

   gareth@conversocial.com
http://www.github.com/gareth-lloyd/twistedstream

More Related Content

PPT
eZ Publish REST API v2
PPT
E zsc2012 rest-api-v2
PDF
Code fast & Break things with Jenkins & Continuous Integration
PPTX
Twitter API, Streaming and SharePoint 2013
PDF
20131008 - Wajug - TweetWall Pro
ODP
Twitter
PPTX
Development of Twitter Application #8 - Streaming API
PPTX
Twitter api
eZ Publish REST API v2
E zsc2012 rest-api-v2
Code fast & Break things with Jenkins & Continuous Integration
Twitter API, Streaming and SharePoint 2013
20131008 - Wajug - TweetWall Pro
Twitter
Development of Twitter Application #8 - Streaming API
Twitter api

Similar to Twitter Streaming API (20)

PDF
Twitter Trend Analyzer
PDF
20130504 - FeWeb - Twitter API
PPTX
#tmeetup BirdHackers API 101
PDF
The Open Source... Behind the Tweets
PDF
CSE5656 Complex Networks - Gathering Data from Twitter
KEY
Twitter API 2.0
PDF
Spring MVC 4.2: New and Noteworthy
PDF
Real-Time Django
PPTX
SignalR for ASP.NET Developers
KEY
Building @Anywhere (for TXJS)
PDF
Real-Time with Flowdock
PPTX
Building WebSocket and Server Side Events Applications using Atmosphere
PDF
Twitter streamingapi rubymongodbv2
PDF
Consuming the Twitter Streaming API with Ruby and MongoDB
PPTX
HATEOAS 101 - Opinionated Introduction to a REST API Style
PDF
500Startups @ Twitter
PPTX
Connected Web Systems
PDF
Server-Sent Events (real-time HTTP push for HTML5 browsers)
PDF
Distributed Reactive Services with Reactor & Spring - Stéphane Maldini
PDF
Live Streaming & Server Sent Events
Twitter Trend Analyzer
20130504 - FeWeb - Twitter API
#tmeetup BirdHackers API 101
The Open Source... Behind the Tweets
CSE5656 Complex Networks - Gathering Data from Twitter
Twitter API 2.0
Spring MVC 4.2: New and Noteworthy
Real-Time Django
SignalR for ASP.NET Developers
Building @Anywhere (for TXJS)
Real-Time with Flowdock
Building WebSocket and Server Side Events Applications using Atmosphere
Twitter streamingapi rubymongodbv2
Consuming the Twitter Streaming API with Ruby and MongoDB
HATEOAS 101 - Opinionated Introduction to a REST API Style
500Startups @ Twitter
Connected Web Systems
Server-Sent Events (real-time HTTP push for HTML5 browsers)
Distributed Reactive Services with Reactor & Spring - Stéphane Maldini
Live Streaming & Server Sent Events
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation_ Review paper, used for researhc scholars
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25-Week II
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
Ad

Twitter Streaming API

  • 1. Do More, Faster The Twitter Streaming API
  • 2. 1. Create a HTTP Request GET /1/statuses/sample.json HTTP/1.1 Authorization: OAuth realm="",oauth_no... Host: stream.twitter.com Accept: */* Sign it with OAuth
  • 3. 2. Handle the response HTTP/1.1 200 OK Content-Type: application/json Transfer-Encoding: chunked Server: Jetty(6.1.25) {"in_reply_to_status_id_str":null,"geo":n ull,"text":"Hey fat boyyyyy!!... What’s missing? No Content-Length header! HTTP Libraries won’t know when to stop consuming
  • 4. 3. Keep handling it • Twitter will keep sending you JSON chunks until you kill the connection • Normal HTTP libraries make this awkward • Try non-blocking / event-based I/O
  • 5. The Streaming API lets you do cool stuff • Sample the firehose, free ~1% • Get interesting subsets of all tweets • By filtering, can get all tweets on a topic • Interact in near-realtime • Process more efficiently
  • 7. At Conversocial, we built a way to search twitter on behalf of our clients. There’s a stream client that receives tweets from the Streaming API
  • 8. We monitor the stream client from a separate thread
  • 9. We still have to poll the REST API to cover gaps between connections
  • 10. Need to disconnect stream client from processing tasks. We do this via a queue.
  • 11. Searches have to be matched back to the terms that produced them - the stream is multiplexed.
  • 12. Thanks for listening! gareth@conversocial.com http://www.github.com/gareth-lloyd/twistedstream

Editor's Notes