{"id":13586838,"url":"https://github.com/making-sense/unofficial_sense_api","last_synced_at":"2025-04-07T18:35:00.288Z","repository":{"id":56897202,"uuid":"125654323","full_name":"making-sense/unofficial_sense_api","owner":"making-sense","description":"Access your Sense data. It's yours.","archived":false,"fork":false,"pushed_at":"2018-03-17T19:07:38.000Z","size":5,"stargazers_count":10,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-13T23:44:39.175Z","etag":null,"topics":["api","data","power","ruby","sense","websocket"],"latest_commit_sha":null,"homepage":null,"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/making-sense.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-17T17:42:10.000Z","updated_at":"2022-06-17T00:33:19.000Z","dependencies_parsed_at":"2022-08-20T17:40:33.164Z","dependency_job_id":null,"html_url":"https://github.com/making-sense/unofficial_sense_api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/making-sense%2Funofficial_sense_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/making-sense%2Funofficial_sense_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/making-sense%2Funofficial_sense_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/making-sense%2Funofficial_sense_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/making-sense","download_url":"https://codeload.github.com/making-sense/unofficial_sense_api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247707824,"owners_count":20982855,"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","data","power","ruby","sense","websocket"],"created_at":"2024-08-01T15:05:51.003Z","updated_at":"2025-04-07T18:35:00.087Z","avatar_url":"https://github.com/making-sense.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Unofficial Sense Api\n\nAccess your Sense data.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'unofficial_sense_api'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install unofficial_sense_api\n\n## Usage\n\nGetting Realtime Data (starts a websocket to `wss://clientrt.sense.com/monitors/#{api.first_monitor_id}/realtimefeed`)\n\n```ruby\nrequire 'sense_api'\nrequire 'pp'\n\napi = SenseApi.new(\"USERNAME\", \"PASSWORD\")\n\ncount = 0\napi.realtime do |json|\n  pp json\n\n  # Be sure to return :exit to terminate the connection and shut down EventMachine!\n  count += 1\n  count \u003e 5 ? :exit : nil\nend\n```\n\nUse `fetch` to pull from REST endpoints of your choice. None have been added to this gem yet.\n\n```ruby\nrequire 'sense_api'\napi = SenseApi.new(\"USERNAME\", \"PASSWORD\")\n\ntimeline = api.fetch(\"https://api.sense.com/apiservice/api/v1/users/#{api.user_id}/timeline?n_item=30\")\n\ntrends = api.fetch(\"https://api.sense.com/apiservice/api/v1/app/history/trends?monitor_id=#{api.first_monitor_id}\u0026scale=WEEK\u0026start=2017-10-23T04:00:00.000Z\")\n\ndevices = api.fetch(\"https://api.sense.com/apiservice/api/v1/app/monitors/#{api.first_monitor_id}/devices?include_merged=true\")\n\nfirst_device_id = devices.first[\"id\"]\n\nfirst_device_details = api.fetch(\"https://api.sense.com/apiservice/api/v1/app/monitors/#{api.first_monitor_id}/devices/#{first_device_id}\")\nfirst_device_hostory = api.fetch(\"https://api.sense.com/apiservice/api/v1/app/history/usage?monitor_id=#{api.first_monitor_id}\u0026granularity=MINUTE\u0026start=2017-10-21T11:00:00.000Z\u0026frames=5400\u0026device_id=#{first_device_id}\")\n```\n\nHere are the endpoints we know about so far:\n\n* `\"https://api.sense.com/apiservice/api/v1/users/#{api.user_id}/timeline?n_item=30\"`\n* `\"https://api.sense.com/apiservice/api/v1/app/history/trends?monitor_id=#{api.first_monitor_id}\u0026scale=WEEK\u0026start=2017-10-23T04:00:00.000Z\"`\n* `\"https://api.sense.com/apiservice/api/v1/app/history/usage?monitor_id=#{api.first_monitor_id}\u0026granularity=SECOND\u0026start=2017-10-25T03:54:00.000Z\u0026frames=5400\"` (`granularity` seems to accept `SECOND` or `MINUTE`)\n\nList devices:\n* `\"https://api.sense.com/apiservice/api/v1/app/monitors/#{api.first_monitor_id}/devices?include_merged=true\"`\n\nYou can add a `device_id` to the history request:\n* `\"https://api.sense.com/apiservice/api/v1/app/history/usage?monitor_id=#{api.first_monitor_id}\u0026granularity=MINUTE\u0026start=2017-10-21T11:00:00.000Z\u0026frames=5400\u0026device_id=SOME_DEVICE_ID\"`\n\nAnd get the data for devices:\n* `\"https://api.sense.com/apiservice/api/v1/app/monitors/#{api.first_monitor_id}/devices/always_on\"`\n* `\"https://api.sense.com/apiservice/api/v1/app/monitors/#{api.first_monitor_id}/devices/unknown\"`\n* `\"https://api.sense.com/apiservice/api/v1/app/monitors/#{api.first_monitor_id}/devices/SOME_DEVICE_ID\"`\n\n### Accessing the API with Curl\n\nIf you'd like, you can skip Ruby entirely and talk to the Sense API with curl:\n\n`curl -k --data \"email=email@example.com\" --data \"password=URL_ENCODED_PASSWORD\" -H \"Sense-Client-Version: 1.17.1-20c25f9\" -H \"X-Sense-Protocol: 3\" -H \"User-Agent: okhttp/3.8.0\" \"https://api.sense.com/apiservice/api/v1/authenticate\"`\n\nThe response will have an `access_token`, as well as a `user_id` and a `monitors` array that you can use to access the Sense APIs. For example:\n\n`curl -k -H \"Authorization: bearer ACCESS_TOKEN\" -H \"Sense-Client-Version: 1.17.1-20c25f9\" -H \"X-Sense-Protocol: 3\" -H \"User-Agent: okhttp/3.8.0\" \"https://api.sense.com/apiservice/api/v1/app/history/usage?monitor_id=A_MONITOR_ID\u0026granularity=SECOND\u0026start=2017-10-24T05:36:00.000Z\u0026frames=5400\"`\n\n## Development\n\nYou can run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaking-sense%2Funofficial_sense_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaking-sense%2Funofficial_sense_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaking-sense%2Funofficial_sense_api/lists"}