{"id":19021605,"url":"https://github.com/codementorio/rest-firebase","last_synced_at":"2025-10-09T21:33:51.071Z","repository":{"id":16827024,"uuid":"19586339","full_name":"CodementorIO/rest-firebase","owner":"CodementorIO","description":"Ruby Firebase REST API client built on top of rest-core","archived":false,"fork":false,"pushed_at":"2020-05-08T14:23:10.000Z","size":75,"stargazers_count":108,"open_issues_count":4,"forks_count":22,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-10-09T21:33:50.821Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodementorIO.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-08T19:37:32.000Z","updated_at":"2025-09-08T03:32:24.000Z","dependencies_parsed_at":"2022-08-04T11:30:12.887Z","dependency_job_id":null,"html_url":"https://github.com/CodementorIO/rest-firebase","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/CodementorIO/rest-firebase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodementorIO%2Frest-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodementorIO%2Frest-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodementorIO%2Frest-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodementorIO%2Frest-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodementorIO","download_url":"https://codeload.github.com/CodementorIO/rest-firebase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodementorIO%2Frest-firebase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002056,"owners_count":26083286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T20:22:41.581Z","updated_at":"2025-10-09T21:33:51.056Z","avatar_url":"https://github.com/CodementorIO.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rest-firebase [![Build Status](https://secure.travis-ci.org/CodementorIO/rest-firebase.png?branch=master)](http://travis-ci.org/CodementorIO/rest-firebase) [![Coverage Status](https://coveralls.io/repos/github/CodementorIO/rest-firebase/badge.png)](https://coveralls.io/github/CodementorIO/rest-firebase) [![Join the chat at https://gitter.im/CodementorIO/rest-firebase](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/CodementorIO/rest-firebase)\n\nby [Codementor][]\n\n[Codementor]: https://www.codementor.io/\n\n## LINKS:\n\n* [github](https://github.com/CodementorIO/rest-firebase)\n* [rubygems](https://rubygems.org/gems/rest-firebase)\n* [rdoc](http://rdoc.info/projects/CodementorIO/rest-firebase)\n* [issues](https://github.com/CodementorIO/rest-firebase/issues) (feel free to ask for support)\n\n## DESCRIPTION:\n\nRuby Firebase REST API client built on top of [rest-core][].\n\n[rest-core]: https://github.com/godfat/rest-core\n\n## FEATURES:\n\n* Concurrent requests\n* Streaming requests\n\n## REQUIREMENTS:\n\n### Mandatory:\n\n* Tested with MRI (official CRuby) and JRuby.\n* gem [rest-core][]\n* gem [httpclient][]\n* gem [mime-types][]\n* gem [timers][]\n\n[httpclient]: https://github.com/nahi/httpclient\n[mime-types]: https://github.com/halostatue/mime-types\n[timers]: https://github.com/celluloid/timers\n\n### Optional:\n\n* gem json or yajl-ruby, or multi_json\n\n## INSTALLATION:\n\n``` shell\ngem install rest-firebase\n```\n\nOr if you want development version, put this in Gemfile:\n\n``` ruby\ngem 'rest-firebase', :git =\u003e 'git://github.com/CodementorIO/rest-firebase.git',\n                     :submodules =\u003e true\n```\n\n## SYNOPSIS:\n\nCheck out Firebase's\n[REST API documentation](https://www.firebase.com/docs/rest-api.html)\nfor a complete reference.\n\n``` ruby\nrequire 'rest-firebase'\n\nf = RestFirebase.new :site =\u003e 'https://SampleChat.firebaseIO-demo.com/',\n                     :secret =\u003e 'secret',\n                     :d =\u003e {:auth_data =\u003e 'something'},\n                     :log_method =\u003e method(:puts),\n                     # `timeout` in seconds\n                     :timeout =\u003e 10,\n                     # `max_retries` upon failures. Default is: `0`\n                     :max_retries =\u003e 3,\n                     # `retry_exceptions` for which exceptions should retry\n                     # Default is: `[IOError, SystemCallError]`\n                     :retry_exceptions =\u003e\n                       [IOError, SystemCallError, Timeout::Error],\n                     # `error_callback` would get called each time there's\n                     # an exception. Useful for monitoring and logging.\n                     :error_callback =\u003e method(:p),\n                     # `auth_ttl` describes when we should refresh the auth\n                     # token. Set it to `false` to disable auto-refreshing.\n                     # The default is 23 hours.\n                     :auth_ttl =\u003e 82800,\n                     # `auth` is the auth token from Firebase. Leave it alone\n                     # to auto-generate. Set it to `false` to disable it.\n                     :auth =\u003e false # Ignore auth for this example!\n\n@reconnect = true\n\n# Streaming over 'users/tom'\nes = f.event_source('users/tom')\nes.onopen   { |sock| p sock } # Called when connected\nes.onmessage{ |event, data, sock| p event, data } # Called for each message\nes.onerror  { |error, sock| p error } # Called whenever there's an error\n# Extra: If we return true in onreconnect callback, it would automatically\n#        reconnect the node for us if disconnected.\nes.onreconnect{ |error, sock| p error; @reconnect }\n\n# Start making the request\nes.start\n\n# Try to close the connection and see it reconnects automatically\nes.close\n\n# Update users/tom.json\np f.put('users/tom', :some =\u003e 'data')\np f.post('users/tom', :some =\u003e 'other')\np f.get('users/tom')\np f.delete('users/tom')\n\n# With Firebase queries (it would encode query in JSON for you)\np f.get('users/tom', :orderBy =\u003e '$key', :limitToFirst =\u003e 1)\n\n# Need to tell onreconnect stops reconnecting, or even if we close\n# the connection manually, it would still try to reconnect again.\n@reconnect = false\n\n# Close the connection to gracefully shut it down.\nes.close\n\n# Refresh the auth by resetting it\nf.auth = nil\n```\n\n## Concurrent HTTP Requests:\n\nInherited from [rest-core][], you can do concurrent requests quite easily.\nHere's a very quick example of making two API calls at the same time.\n\n``` ruby\nrequire 'rest-firebase'\nfirebase = RestFirebase.new(:log_method =\u003e method(:puts))\nputs \"httpclient with threads doing concurrent requests\"\na = [firebase.get('users/tom'), firebase.get('users/mom')]\nputs \"It's not blocking... but doing concurrent requests underneath\"\np a.map{ |r| r['name'] } # here we want the values, so it blocks here\nputs \"DONE\"\n```\n\nIf you prefer callback based solution, this would also work:\n\n``` ruby\nrequire 'rest-firebase'\nfirebase = RestFirebase.new(:log_method =\u003e method(:puts))\nputs \"callback also works\"\nfirebase.get('users/tom') do |r|\n  p r['name']\nend\nputs \"It's not blocking... but doing concurrent requests underneath\"\nfirebase.wait # we block here to wait for the request done\nputs \"DONE\"\n```\n\nFor a detailed explanation, see:\n[Advanced Concurrent HTTP Requests -- Embrace the Future][future]\n\n[future]: https://github.com/godfat/rest-core#advanced-concurrent-http-requests----embrace-the-future\n\n### Thread Pool / Connection Pool\n\nUnderneath, rest-core would spawn a thread for each request, freeing you\nfrom blocking. However, occasionally we would not want this behaviour,\ngiving that we might have limited resource and cannot maximize performance.\n\nFor example, maybe we could not afford so many threads running concurrently,\nor the target server cannot accept so many concurrent connections. In those\ncases, we would want to have limited concurrent threads or connections.\n\n``` ruby\nRestFirebase.pool_size = 10\nRestFirebase.pool_idle_time = 60\n```\n\nThis could set the thread pool size to 10, having a maximum of 10 threads\nrunning together, growing from requests. Each threads idled more than 60\nseconds would be shut down automatically.\n\nNote that `pool_size` should at least be larger than 4, or it might be\nvery likely to have _deadlock_ if you're using nested callbacks and having\na large number of concurrent calls.\n\nAlso, setting `pool_size` to `-1` would mean we want to make blocking\nrequests, without spawning any threads. This might be useful for debugging.\n\n### Gracefully shutdown\n\nTo shutdown gracefully, consider shutdown the thread pool (if we're using it),\nand wait for all requests for a given client. For example:\n\n``` ruby\nRestFirebase.shutdown\n```\n\nWe could put them in `at_exit` callback like this:\n\n``` ruby\nat_exit do\n  RestFirebase.shutdown\nend\n```\n\nIf you're using unicorn, you probably want to put that in the config.\n\n## Powered sites:\n\n* [Codementor][]\n\n## CHANGES:\n\n* [CHANGES](CHANGES.md)\n\n## CONTRIBUTORS:\n\n* Lin Jen-Shin (@godfat)\n* Yoshihiro Ibayashi (@chanibarin)\n\n## LICENSE:\n\nApache License 2.0 (Apache-2.0)\n\nCopyright (c) 2014-2019, Codementor\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodementorio%2Frest-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodementorio%2Frest-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodementorio%2Frest-firebase/lists"}