Liking cljdoc? Tell your friends :D


A lightweight clojure client for Firebase based using the REST API. Basically Charmander 2.0


master codecov Dependencies Status Clojars Project


For fire you will need to create a Realtime Database on Firebase and retrieve the service account credentials.

  1. Get the json file containing your service account creditials by following the instruction here
  2. Copy the contents of your .json into the GOOGLE_APPLICATION_CREDENTIALS environment variable. In your ~/.bash_profile and in Travis CI you should escape your credentials using singe quotes (').


[alekcz/fire "0.5.0"]

Interacting with Realtime Database

Creating your auth token

(require  '[fire.core :as fire]
          '[fire.auth :as auth])
(def auth (auth/create-token "GOOGLE_APPLICATION_CREDENTIALS"))

Write to the specified location (will overwrite any existing data):

    (fire/write! "protected-db-name" "/path" {:map "with data"} auth)
    (fire/write! "public-db-name" "/path" {:map "with data"} nil)
    ; => {:map "with data"}

Read data from the specified location:

    (fire/read "protected-db-name" "/path" auth)
    (fire/read "public-db-name" "/path" nil)
    ; => {:map "with data"}

Update data at the specified location (only updates the specified fields):

     (fire/update! "protected-db-name" "/path" {:more "data"} auth)
     (fire/update! "public-db-name" "/path" {:more "data"} nil)
     ; => {:map "with data" :more "data"}

Add data at the specified location with an automatically generated key:

     (fire/push! "protected-db-name" "/path" {:map "with data"} auth)
     (fire/push! "public-db-name" "/path" {:map "with data"} nil)
     ; => {"name" "-IoZ3DZlTTQIkR0c7iVK"}

Delete at the specified locations:

    (fire/delete! "protected-db-name" "/path" auth)
    (fire/delete! "public-db-name" "/path" nil)
    ; => nil

Query data at the specified locations: Note that if the child key is not indexed firebase will respond with error 400. Also :orderBy is required for all queries. See the Firebase query docs for more info.

    (fire/read "protected-db-name" "/path" auth {:query {:orderBy "child-key" :startAt 10 :endAt 50}})
    (fire/read "protected-db-name" "/path" auth {:query {:orderBy "child-key" :equalTo 10}})
    (fire/read "public-db-name" "/path" nil {:query {:orderBy "child-key" :limitToFirst 10}})
    (fire/read "public-db-name" "/path" nil {:query {:orderBy "child-key" :limitToLast 3}})
    ; => nil

Interacting with Firebase Stsorage

Creating your auth token

(require  '[ :as storage]
          '[fire.auth :as auth])
(def auth (auth/create-token "GOOGLE_APPLICATION_CREDENTIALS"))

Upload data or a file to Firebase Storage

(spit "path/on/firebase.txt" "this is fire")
(storage/upload! "path/on/firebase.txt" "path/on/disk/storage.txt" "text/plain" auth)
(storage/upload! "path/on/firebase.txt" non-string-data-in-memory  "text/plain" auth)

Download data to memory or a file from Firebase Storage

(store/download "path/on/firebase.txt" auth) ;=> "this is fire"
(store/download-to-file "path/on/firebase.txt" "downloads/storage.txt" auth)
(slurp "downloads/storage.txt") ;=> "this is fire"

Add data at the specified location with an automatically generated key:

(store/delete! "path/on/firebase.txt" auth) 


Special thanks to:


Copyright © 2020 Alexander Oloo

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at

Can you improve this documentation? These fine people already did:
Alexander Oloo & Alex Oloo
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close