Access firebase database using php

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Pick a username Email AddressPassword

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

  • Products
  • Use Cases
  • Pricing
  • Docs
    • Overview
    • Fundamentals
    • Build
    • Release & Monitor
    • Engage
    • Reference
    • Samples
  • Community
  • Support
  • Go to console

Stay organized with collections Save and categorize content based on your preferences.

Reading Data with GET

We can read data from our Firebase database by issuing a GET request to its URL endpoint. Let's continue with our blog example from the previous section and read all of our blog post data:

curl 'https://docs-examples.firebaseio.com/fireblog/posts.json?print=pretty'

A successful request will be indicated by a 200 OK HTTP status code, and the response will contain the data we're retrieving.

Adding URI Parameters

The REST API accepts several query parameters when reading data from our Firebase database. Listed below are the most commonly used parameters. For a full list, refer to the REST API Reference.

auth

The auth request parameter allows access to data protected by Firebase Realtime Database Rules, and is supported by all request types. The argument can either be your Firebase app's secret or an authentication token, as described in the Users in Firebase Projects. In the following example we send a GET request with an auth parameter, where CREDENTIAL is either your Firebase app's secret or an authentication token:

curl 'https://docs-examples.firebaseio.com/auth-example.json?auth=CREDENTIAL'

print

Specifying print=pretty returns the data in a human-readable format.

curl 'https://docs-examples.firebaseio.com/fireblog/posts.json?print=pretty'

Specifying print=silent returns a 204 No Content on success.

curl 'https://docs-examples.firebaseio.com/fireblog/posts.json?print=silent'

callback

To make REST calls from a web browser across domains you can use JSONP to wrap the response in a JavaScript callback function. Add callback= to have the REST API wrap the returned data in the callback function you specify. For example: