Connected successfully



C# Application to Firebase Database - Retrieving The Entire JSON Tree



In todays article we will go through how to retrieve all data from Googles Firebase database using a C# application, this article will not however go through the retrieving specific or individual data but rather we will be returning the entire Json tree. Again as explained in all posts and articles before there is no database authentication being used in this example.
If however you are wanting to have some form of authentication added to your project check out the below
Authenticating Your C# Application with the Firebase Database

Be sure to have a read up on some of the other posts we have as you may find them of extreme use. Especially if wanting to remove those random base-64 keys being generated when inserting and updating data. Also find out how to retrieve specific children nodes.The list for which can be found below:
Inserting data in to the Firebase database
Updating data in the Firebase database
Deleting data in Firebase database
Inserting Individual parent and child nodes in to the Firebase database
Removing random base-64 keys from the parent nodes within the Firebase database
Retrieving Individual parent and child nodes from the Firebase database



So to begin with we will look at the namespaces being used within this example of code. The first header we see is System which is present as we are later making use of the console to display any returned data. system.Net is needed as we will be making a web request to our firebase project online as well as a web response. Finally, we also have System.IO which enables us to the stream reader allowing us to read text from a stream of data.



We will now move on to main section of the code which can be found in the snippet below



We start of by creating a Http web request to our firebase project making use of our URL, be sure to change the URL according to what you have in your specified project. Once the request has been made we then create a Http web response and by using a stream reader we enable ourselves the ability to read in text format the JSON. As the code in is within a while loop the stream of data is constant meaning our recovered version the JSON is always liable to change.

This could be changed to periodic frequencies depending on what exactly you are wanting to do with it, but the end result in this project will always be the same. You can then go on to further manipulate this JSON data in what you want. The full source code can be found in the below snippet. Hope this is of use to you guys, plenty more posts and articles coming your way. Hope you enjoy and if you have any questions and or queries do feel free to contact us via the form on our website!




Be sure to have a read up on some of the other posts we have as you may find them of extreme use. Especially if wanting to remove those random base-64 keys being generated when inserting and updating data. Also find out how to retrieve specific children nodes.The list for which can be found below:
Inserting data in to the Firebase database
Updating data in the Firebase database
Deleting data in Firebase database
Inserting Individual parent and child nodes in to the Firebase database
Removing random base-64 keys from the parent nodes within the Firebase database
Retrieving Individual parent and child nodes from the Firebase database