33

First of all I'd like to apologize if this question is to abstract or unsuitable for this site. I really don't know where else to ask.

Currently I have developed apps in iOS and Android. They keep all their state in firebase, so everything is instantly persisted to the Firebase Realtime Database.

Before a user is created I populate the realtime database manually with some data that is expected to be there so that the app can run, such as config data for the user. When I'm "done" using the app I view the data directly in the Firebase console.

Now I want a backend to do the job I have done manually. I want the backend to be able to populate the realtime database and I want it also to be able to retrieve data from Firebase. I would like this to be done from a Java backend(Spring MVC but that might not be critical information right now).

How should I go about doing this? Googling hasn't gotten me that far(java+backend+firebase mostly tells me that "Firebase offers a backend to Android Java").

If this is the wrong place to post this, then please suggest where I can post it instead.

Edit: I am aware of the Server SDK. I am rather referring on how to implement this in what would typically be a stateless rest solution than specifically how the methods in the Server SDK are executed.

adjuremods
  • 2,938
  • 2
  • 12
  • 17
why_vincent
  • 2,172
  • 9
  • 33
  • 49
  • 3
    Between the [Firebase SDK for server-side Java](https://firebase.google.com/docs/server/setup) and articles like [this](https://cloud.google.com/solutions/mobile/mobile-app-backend-services#firebase-appengine-flexible) and [this](https://firebase.googleblog.com/2013/03/where-does-firebase-fit-in-your-app.html), you should have enough information to get started. If you have problems making it work, post what you've done and where you are stuck. – Frank van Puffelen Nov 01 '16 at 14:17
  • does the Firebase SDK for server-side Java only listen? Or, like the REST-ful API, can it query the entire JSON tree? – Thufir Jul 04 '17 at 01:24

2 Answers2

19

Firebase has its own RestApi, you can use it in your api https://firebase.google.com/docs/database/rest/start

Alex Shutov
  • 3,217
  • 2
  • 13
  • 11
7

Firebase also provides dependencies to work with Firebase Realtime Database.

Gradle Dependency:

dependencies {
  implementation 'com.google.firebase:firebase-admin:6.3.0'
}

Maven Dependency:

<dependency>
  <groupId>com.google.firebase</groupId>
  <artifactId>firebase-admin</artifactId>
  <version>6.3.0</version>
</dependency>

For more details visit Docs : https://firebase.google.com/docs/admin/setup#add_firebase_to_your_app

Shrinivas
  • 1,223
  • 16
  • 13
  • 1
    The Admin SDK is not suitable for Java software that will be distributed amongst users. It requires the usage of an unrestricted service account file which could be used maliciously if someone decompiled the application and extracted the relevant data. For this reason, if you're using Java for the client part of your app (and not the admin/back-end side), you should use the REST API. – jskidd3 Jun 28 '19 at 00:11
  • @jskidd3 So there's no Java API for firebase-auth? I found the dependencies, but all they contain is .aar files... – Jorn Apr 14 '20 at 13:35