{"id":14973126,"url":"https://github.com/mownier/pyrobase","last_synced_at":"2025-10-26T22:31:49.356Z","repository":{"id":62451312,"uuid":"95200476","full_name":"mownier/pyrobase","owner":"mownier","description":"An iOS lightweight wrapper for Firebase REST API","archived":false,"fork":false,"pushed_at":"2019-04-03T14:01:18.000Z","size":105,"stargazers_count":90,"open_issues_count":1,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-02-01T00:51:06.125Z","etag":null,"topics":["firebase","framework","ios","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mownier.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.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":"2017-06-23T08:34:19.000Z","updated_at":"2024-07-15T20:30:25.000Z","dependencies_parsed_at":"2022-11-01T23:45:23.664Z","dependency_job_id":null,"html_url":"https://github.com/mownier/pyrobase","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mownier%2Fpyrobase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mownier%2Fpyrobase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mownier%2Fpyrobase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mownier%2Fpyrobase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mownier","download_url":"https://codeload.github.com/mownier/pyrobase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238408509,"owners_count":19467103,"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","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":["firebase","framework","ios","swift"],"created_at":"2024-09-24T13:48:09.911Z","updated_at":"2025-10-26T22:31:49.011Z","avatar_url":"https://github.com/mownier.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pyrobase\nAn iOS lightweight wrapper for Firebase REST API. For more Firebase's details, see it [here.](https://firebase.google.com/docs/reference/rest/database/) It is written in Swift and has 100% code coverage.\n\n## Installation\n\n### Cocoapods\n```shell\n$ pod repo update\n$ pod init\n$ vim Podfile\n// Add `pod Pyrobase` in your podfile\n$ pod install\n```\n\n### Carthage\n```shell\n$ brew install carthage\n$ vim Cartfile\n// Add `github \"mownier/Pyrobase\" ~\u003e 1.0` in your cartfile\n$ carthage update\n```\n\n## Usage\n\n### Authentication\n\nMake sure to copy `PyroAuthInfo.plist`. And keep in mind the bundle identifier where the said file is added. \n\n#### Initialization\n```swift\nlet apiKey = \"yourFirebaseAPIKey\"\nlet bundleIdentifier = \"com.my.app\"\nlet auth = PyroAuth.create(key: apiKey, bundleIdentifier: bundleIdentifier)\n// The variable 'auth' is nil if you provide an invalid bundle identifier.\n// Otherwise, you are good to go.\n// NOTE: If you build this project as framework, you can opt out\n//       providing the bundle identifier. The default value\n//       is the project's bundle identifier\n```\n\n#### Sign In\n```swift\nauth.signIn(email: email, password: password) { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n        // 'data' is PyroAuthContent\n    }\n}\n```\n\n#### Register\n```swift\nauth.register(email: email, password: password) { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n        // 'data' is PyroAuthContent\n    }\n}\n```\n\n#### Refresh Token\n```swift\nauth.refresh(token: \"refreshToken\") { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n        // 'data' is PyroAuthTokenContent\n    }\n}\n```\n\n#### Send Password Reset\n```swift\nauth.sendPasswordReset(email: \"me@me.com\") { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n        // 'data' is Bool\n    }\n}\n```\n\n### REST\n\n#### Initialization\n```swift\nlet baseURL = \"https://foo.firebaseio.com\"\nlet accessToken = \"accessToken\"\nlet pyrobase = Pyrobase.create(baseURL: baseURL, accessToken: accessToken)\n```\n\n#### GET Request\n```swift\npyrobase.get(path: \"users/abcde12345wert\", query: [:]) { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n    }\n}\n```\n\n#### POST Request\n```swift\npyrobase.post(path: \"messages\", value: [\"message\": \"hello world\", \"user_id\": \"abcde12345qwert\"]) { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n    }\n}\n```\n\n#### PUT Request\n```swift\npyrobase.put(path: \"users/abcde12345wert\", value: [\"first_name\": \"Juan\", \"last_name\": \"Dela Cruz\"]) { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n    }\n}\n```\n\n#### PATCH Request\n```swift\npyrobase.patch(path: \"users/abcde12345wert\", value: [\"first_name\": \"Jose\"]) { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n    }\n}\n```\n\n### Transaction\n\n#### Initialization\n```swift\nlet baseURL = \"https://foo.firebaseio.com\"\nlet accessToken = \"accessToken\"\nlet transaction = PyroTransaction.create(baseURL: baseURL, accessToken: accessToken)\n```\n#### Run\n```swift\ntransaction.run(\n    parentPath: \"posts/yuiop98765nbcwe\",\n    childKey: \"likes_count\", \n    mutator: { data in\n    \tlet likesCount = data as! Int\n    \treturn likesCount + 1\n}) { result in\n    switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n    }\n}\n```\n\n\n### Event Source\n\n#### Callback\n```swift\nclass StreamCallback: PyroEventSourceCallback {\n\n    func pyroEventSource(_ eventSource: PyroEventSource, didReceiveError error: Error) {\n        // Do some stuff\n    }\n    \n     func pyroEventSource(_ eventSource: PyroEventSource, didReceiveMessage message: PyroEventSourceMessage) {\n        // Do some stuff\n    }\n\n    func pyroEventSourceOnOpen(_ eventSource: PyroEventSource) {\n        // Do some stuff\n    }\n    \n    func pyroEventSourceOnClosed(_ eventSource: PyroEventSource) {\n        // Do some stuff\n    }\n    \n    func pyroEventSourceOnConnecting(_ eventSource: PyroEventSource) {\n        // Do some stuff\n    }\n}\n```\n\n#### Initialization\n```swift\nlet callback = StreamCallback()\nlet baseURL = \"https://foo.firebaseio.com\"\nlet accessToken = \"accessToken\"\nlet eventSource = PyroEventSource.create(baseURL: baseURL, accessToken: accessToken)\neventSource.callback = callback\n```\n\n#### Stream\n```swift\neventSource.stream(\"chat/rooms/hdjye53910kwdop\")\n```\n\n#### Close\n```swift\neventSource.close()\n```\n\n### Query Parameters\nAlways keep in mind of adding `.indexOn` in your rules for the path you want to query. You may receive a `badRequest` error if you don't set it.\n\n```swift\nlet query = [\"orderBy\": \"\\\"$key\\\"\", \"limitToFirst\": 1]\npyrobase.get(\"posts\", query: query) { result in\n   switch result {\n    case .failed(let error):\n        print(error)\n        // Do some stuff\n            \n    case .succeeded(let data):\n        print(data)\n        // Do some stuff\n    }\n}\n```\n\n\n### License\n\nMIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmownier%2Fpyrobase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmownier%2Fpyrobase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmownier%2Fpyrobase/lists"}