5

Is there a way where you can actively have a listener for a Firebase Database in Python?

For instance, I have a node user in the database, I want to be able to actively listen for any changes that immediately happens for a user and immediately make changes on it.

For now, I'm just using a for-loop. In my case, I have something like sync_state for user with the integer value 3. It gets changed to 4 when the session has been ended, I want to update value for that user.

Right now, I run the for-loop periodically, but it won't be efficient in the future when I have a lot of users in my database. Is there a way to do this in a python-ish way than using Node.JS?

1 Answer 1

3

You can use Firebase's REST Streaming API: https://firebase.google.com/docs/database/rest/retrieve-data#section-rest-streaming.

The blog post that introduced that API, includes some samples for Python: https://firebase.googleblog.com/2014/03/announcing-streaming-for-firebase-rest.html

There are some Python libraries that wrap that API: https://www.google.nl/webhp#q=firebsae%20python%20streaming

Sign up to request clarification or add additional context in comments.

1 Comment

Another similar question with a concrete example using Python firebase-admin: stackoverflow.com/a/53020497/4262057

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.