Can I create a different hashtag stream using the public streams API for each visitor to my web app who authenicates their account?


#1

Hey guys,

It would work like this.

  • User visits my website, and enters their twitter username/password to authorize my web app to make calls on their behalf.
  • The user types in a hashtag, and they are given a stream of tweets containing that hashtag in a box they can look at.

The public stream api docs say

“Connections: Each account may create only one standing
connection to the public endpoints, and connecting to a public stream
more than once with the same account credentials will cause the oldest
connection to be disconnected.Clients which make excessive
connection attempts (both successful and unsuccessful) run the risk of
having their IP automatically banned.”

It seems like my web application will work without getting me IP banned, but I wanted confirmation. Is this type of web application possible within the api limits? Thanks! Would it matter how many visitors visited my site and did this? are there limits based on that? Thanks.


#2

Maybe you don’t need users to authenticate and it is enough with yours tokens…


#3

Hi @StreamFramer, I would add the hashtag to your track param and restart the stream. Post process the incoming Tweets within your app and distribute them to the appropriate clients. If you experience delay in restarting the stream you can attempt to backfill with the search API (although is does not promise completeness).

Depending on how far you want to take this, you may run into limitation on the public API. If you get very serious and need enterprise level APIs checkout Gnip Powertrack.


#4

Hey,

Thanks for the reply Jon! I have an additional question / concern regarding your answer. The documentation states:
“ConnectionsEach account may create only one standing
connection to the public endpoints, and connecting to a public stream
more than once with the same account credentials will cause the oldest
connection to be disconnected.Clients which make excessive
connection attempts (both successful and unsuccessful) run the risk of
having their IP automatically banned.”

Each time I change my track am I making a connection attempt? If I am what are the limits on how often I can change the track to push the data out to the proper clients? If i’m not making connection attempts, how often can I change tracks and request a new stream? Thanks!


#5

@StreamFramer, good points and questions.

If you are using Twitter Sign-in, you should be able to open a streaming connection for each of your users. You will use the user’s access tokens and the rate limit should fall on the user.

The streaming API is not designed to be as dynamic as you are probably intending to use it. The rate-limits on re-connecting are not disclosed for this particular end point. I would design your user experience to keep this in mind.

You can allow your users to change their track parameters at anytime, but communicate to the user that changes won’t take effect immediately. You could then create a cron that looks for updated track parameters and restarts the related stream. This way stream restarts are under your control, and a user can not spam the the Twitter API.

You will also want to implement back-off strategies. Documentation start at “Reconnecting” on this page.