Skip to content
a ruby implementation for the withing WIFI connected bodyscale
Find file
Pull request Compare This branch is 40 commits behind simplificator:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This is a ruby implementation for the Withings API. Description of the API can be found here:

Versions ==

Note that this release (0.4.0) breaks the API of previous releases:

User.authenticate ===

User.authenticate() has been replaced by User.userlist

There is no description available and no guarantee on the order that users are returned by the API (and yes, there can be many users for a single Account) so it seems best to leave the decision to the users of the API.

The old method is still there but please update your code. It will be removed in the next release.

MeasurementGroup ===

MeasurementGroup#createt_at has been replaced by MeasurementGroup#taken_on

Created at is usually the timestamp at which a record was created. But MeasurementGroup#created_at was the timestamp when you actually took the measurement. You can also take measurements (via the Web UI on which are for a past date. The record is created today, but the measurement was taken on 2 weeks ago.

The old method is still there but please update your code. It will be removed in the next release.


gem install simplificator-withings


The WBS API provides a way to login by user_id and public_key. You can either ask your users to enter the user_id/public_key manually (they can be found in the sharing overlay on or ask them for email/password once and then use those credentials to authenticate through the API (User.authenticate(email, password)). The User instance returned will have the user_id and public_key attributes populated and you can store them for further use.

As soon as you have user_id/public_key available you can either use or to create a User instance. While will make an API call to populate the attributes, just requires user_id/public_key.


  • Integration Test? But i don't want to share my credentials… Perhaps with a test account on withings? Solution from Withings support: Hi,

    The easiest is that you just create a regular account (, associate it with one scale, then create a user (like any regular customer).

    Once this is done, the account is activated. You may then go to My account/My scale and dissociate the scale, the account will stay opened. That account may be used by who ever you think it should for test purposes and will not be associated to a specific scale.

    Thanks for your enquiry !



  • The gem is still under development and the API might change a bit.

  • Authentication by user_id/public_key is only supported when the user has activated sharing. He can do this either in the sharing overlay on or through the api (user.share <LIST OF DEVICES>) after authentication by email/password

  • As soon as the user sets sharing to false (user.share = false) the public_key is reset and upon next activation of sharing a new public_key is assigned.

  • All the methods making remote calls can throw Withing::ApiError if something goes wrong (wrong public_key, missing parameters, …). You can find more details on the error by looking at the status code in the error.

How To

Require the API implementation

require 'rubygems'
require 'withings'

All classes are name-spaced, if your other code allows you can include Withings

include Withings

A user can be authenticated with email address and password

user = User.userlist('<YOUR EMAIL ADDRESS>', '<YOUR PASSWORD>').first # or any other user which is returned

Or you can fetch details if you have the user id and public key


If you already have user id and public key and you do not need further information on the user

user = => '<YOUR USER ID>', :public_key => '<YOUR PUBLIC_KEY>')

enable/disable sharing, disabling it will reset the public key

user.share() # share all
user.share(Withings::SCALE, Withings::BLOOD_PRESSURE_MONITOR)

You can handle subscriptions through the API (all devices currently known => Scale + Blood Pressure Monitor)

user.subscribe_notification('', 'test subscription')

Specify what devices you are interested

user.subscribe_notification('', 'test subscription', Withings::SCALE, Withings::BLOOD_PRESSURE_MONITOR)


And finally you can get measurements, after all this is what it's for

user.measurement_groups(:per_page => 10, :page => 1, :end_at =>
user.measurement_groups(:category => MeasurementGroup::CATEGORY_TARGET)
user.measurement_groups(:last_updated_at =>
user.measurement_groups(:start_at =>, :end_at =>
user.measurement_groups(:measurement_type => MeasurementGroup::TYPE_FAT)
user.measurement_groups(:device => Withings::SCALE)

Note on keys in hashes

Keys to constructors (User, MeasurementGroup and NotificationDescription) and methods (User.measurement_groups) can be either String or Symbol

Note on naming convention

The WBS API has parameter with shortened names (e.g. 'grpid') or names not following a consistent naming pattern. While this API implementation tries to stick as close to the API as possible it also tries to unify and simplify the parameter names. The constructors for User, MeasurementGroup and NotificationDescription accept the names provided by the API but convert the names then to a more “ruby” way. An exception to this are the “id” and “publickey” parameters for, they are accepted as “user_id” and “public_key” as well.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.


HTTParty is used for making the HTTP requests and Shoulda and Mocha are used for testing. Thanks for these Gems.


Copyright © 2010 simplificator. See LICENSE for details.

Something went wrong with that request. Please try again.