Stream API - Swift

ios
streaming
swift
api

#1

Hey guys, I have never used the streaming API and making some researches, I couldn’t find relevant topics related to this API in Swift language.
Could someone tell me if the Streaming API works in Swift and give me a simple example of a search on Twitter using the Streaming API?
I also would appreciate sites or docs with examples.
Thanks!


#2

Hi @gutiagos, you should ask this in the Fabric forum to get exposed to more mobile devs.

I am not a mobile developer, but the streaming API requires an open HTTP request. There a few reason this may not really be a good idea on mobile, so think through your strategy. You will want to be conscious of your user’s data plan and battery. You may want to consider consuming and processing the stream on your own server, then have your app poll or connect via a socket connection. This way your app can regulate itself.


#3

Following on from the previous response - there is a Swift library called Swifter which works with the Twitter Streaming API, and it contains some examples. I wouldn’t recommend you use it extensively on mobile for the reasons @joncipriano mentions, but it should work fine. You’ll want to filter on the search terms you’re after in your connection request.


#5

Thank you! That helped me a lot. I think the better thing to do is process the stream on the server side.


#6