How to emulate a streaming API?

I need to maintain a almost real-time access to an API(so that the program gets notified immediately when the API response changes). The API provided is non-realtime. What I want is something similar to Twitter's streaming API( https://dev.twitter.com/docs/streaming-api ).

I could send an API call every second but that would be too inefficient. What would be better ways to do this? I'll probably be doing this in Python or Node.js.

Since you're the client you have absolutely no way of knowing if the API response changes other than polling the API every few seconds.

reduce API calls by using the minimum time you're guaranteed to have no changes or the maximum time you can afford not knowing of changes.