{"id":15288750,"url":"https://github.com/zokioki/fitbit_api","last_synced_at":"2025-10-15T08:06:34.844Z","repository":{"id":36128985,"uuid":"40432289","full_name":"zokioki/fitbit_api","owner":"zokioki","description":"A Ruby interface to the Fitbit Web API.","archived":false,"fork":false,"pushed_at":"2024-09-02T07:59:08.000Z","size":263,"stargazers_count":25,"open_issues_count":1,"forks_count":21,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-07T02:06:26.758Z","etag":null,"topics":["api","fitbit","oauth2","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/zokioki.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-09T10:06:34.000Z","updated_at":"2025-04-06T08:48:43.000Z","dependencies_parsed_at":"2023-01-16T23:31:03.133Z","dependency_job_id":"b04826ad-ee0e-4293-8817-c84d690eb924","html_url":"https://github.com/zokioki/fitbit_api","commit_stats":{"total_commits":236,"total_committers":3,"mean_commits":78.66666666666667,"dds":0.008474576271186418,"last_synced_commit":"7edc3442b6d566d43c447389ef5052949f934c50"},"previous_names":["zokioki/fitbyte"],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/zokioki/fitbit_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokioki%2Ffitbit_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokioki%2Ffitbit_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokioki%2Ffitbit_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokioki%2Ffitbit_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zokioki","download_url":"https://codeload.github.com/zokioki/fitbit_api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokioki%2Ffitbit_api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266287824,"owners_count":23905461,"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":["api","fitbit","oauth2","rails","ruby"],"created_at":"2024-09-30T15:53:03.699Z","updated_at":"2025-10-15T08:06:29.808Z","avatar_url":"https://github.com/zokioki.png","language":"Ruby","readme":"# FitbitAPI\n\n[![Gem Version](https://img.shields.io/gem/v/fitbit_api)](https://rubygems.org/gems/fitbit_api)\n[![CI Workflow](https://img.shields.io/github/actions/workflow/status/zokioki/fitbit_api/ci.yml?branch=master)](https://github.com/zokioki/fitbit_api/actions/workflows/ci.yml)\n\nFitbitAPI provides a Ruby interface to the [Fitbit Web API](https://dev.fitbit.com/reference/web-api).\n\n## Installation\n\nTo install the latest release:\n\n    $ gem install fitbit_api\n\nTo include in a Rails project, add it to the Gemfile:\n\n```ruby\ngem 'fitbit_api'\n```\n\n## Getting Started\n\nTo use the Fitbit API, you must register your application at [dev.fitbit.com](https://dev.fitbit.com/apps). After registering, you should have access to the **CLIENT ID** and **CLIENT SECRET** values for use in instantiating a *FitbitAPI::Client* object.\n\n### Rails\n\nYou can reference the [fitbit_api_rails](https://github.com/zokioki/fitbit_api_rails) repo as a simple example of how to use this gem within a Rails project.\n\n### Quickstart\n\nIf you already have a user's token data and Fitbit user_id:\n\n```ruby\nclient = FitbitAPI::Client.new(client_id: 'XXXXXX',\n                               client_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',\n                               access_token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',\n                               refresh_token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',\n                               expires_at: 1234567890,\n                               user_id: 'XXXXXX')\n```\n\n### OAuth 2.0 Authorization Flow\n\n- Create a client instance (ensure that `redirect_uri` is passed in):\n\n```ruby\nclient = FitbitAPI::Client.new(client_id: 'XXXXXX',\n                               client_secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',\n                               redirect_uri: 'http://example.com/handle/callback')\n```\n\n- Generate a link for your app's Fitbit authorization page:\n\n```ruby\nclient.auth_url\n# =\u003e https://fitbit.com/oauth2/authorize?client_id=123XYZ\u0026redirect_uri=...\n```\n\n- Follow the generated link to Fitbit's authorization page. After granting permission for your app, you're sent to the `redirect_uri`, with an appended authorization `code` param, which you'll exchange for an access token:\n\n```ruby\nclient.get_token(auth_code)\n```\n\nYou're now authorized and can make calls to Fitbit's API.\n\n### Interacting with the API\n\nOnce a valid token has been generated, you're able to make API calls via the client object:\n\n```ruby\nclient.food_logs Date.today\n# =\u003e { \"foods\" =\u003e [{ \"isFavorite\" =\u003e true, \"logDate\" =\u003e \"2015-06-26\", \"logId\" =\u003e 1820, \"loggedFood\" =\u003e { \"accessLevel\" =\u003e \"PUBLIC\", \"amount\" =\u003e 132.57, \"brand\" =\u003e \"\", \"calories\" =\u003e 752, ...}] }\n```\n\nTo make responses more easily suited for attribute-assignment, they can be parsed to return a hash whose keys are in snake_case format. This can be done by setting the client's `snake_case_keys` option to `true`:\n\n```ruby\nclient.snake_case_keys = true\nclient.food_logs Date.today\n# =\u003e { \"foods\" =\u003e [{ \"is_favorite\" =\u003e true, \"log_date\" =\u003e \"2015-06-26\", \"log_id\" =\u003e 1820, \"logged_food\" =\u003e { \"access_level\" =\u003e \"PUBLIC\", \"amount\" =\u003e 132.57, \"brand\" =\u003e \"\", \"calories\" =\u003e 752, ...}] }\n```\n\nSimilarly, all arguments passed in through a POST request are automatically converted to camelCase before they hit Fitbit's API, making it easy to keep your codebase stylistically consistent. For example, all of the following would result in valid API calls:\n\n```ruby\n# options with snake_cased keys\nclient.log_activity activity_id: 12345, duration_millis: '50000'\n# options with camelCased keys\nclient.log_activity activityId: 54321, durationMillis: '44100'\n# options with mixed snake and camel cased keys\nclient.log_activity activity_id: 12345, durationMillis: '683300'\n```\n\n### Options\n\nWhen initializing a `FitbitAPI::Client` instance, you're given access to a handful of options:\n\n| Option               | Description                  | Default        |\n| -------------------- | ---------------------------- | -------------- |\n| `api_version`        | API version to be used when making requests | `\"1\"` |\n| `unit_system`        | The measurement unit system to use for response values | `\"en_US\"` |\n| `locale`             | The locale to use for response values | `\"en_US\"` |\n| `scope`              | A list of permissions being requested (array or space-delimited string) | `%w[activity nutrition profile settings sleep social weight heartrate respiratory_rate oxygen_saturation cardio_fitness temperature electrocardiogram irregular_rhythm_notifications]` |\n| `snake_case_keys`    | Transform response payload's keys to snake case format | `false` |\n| `symbolize_keys`     | Transform response payload's keys to symbols | `false` |\n| `auto_refresh_token` | Automatically refreshes the access token once expired | `true` |\n| `on_token_refresh`   | A callback to be invoked whenever the access token is refreshed | `nil` |\n\nIf using this library in Rails, you can configure these options globally in an initializer:\n\n```ruby\n# config/initializers/fitbit_api.rb\n\nFitbitAPI.configure do |config|\n  config.client_id       = 'XXXX'\n  config.client_secret   = 'xxxx'\n  config.snake_case_keys = true\n  config.symbolize_keys  = true\nend\n```\n\n## License\n\nThis gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzokioki%2Ffitbit_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzokioki%2Ffitbit_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzokioki%2Ffitbit_api/lists"}