Skip to content

Instantly share code, notes, and snippets.

@valvallow
Created December 22, 2016 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valvallow/34120ee35db0f7f1099357f29ad68fe0 to your computer and use it in GitHub Desktop.
Save valvallow/34120ee35db0f7f1099357f29ad68fe0 to your computer and use it in GitHub Desktop.
get withings data command
#!/bin/sh
NOW=`date +%s`
YESTERDAY=`date --date='-1day' +%s`
wget -qO - "http://wbsapi.withings.net/measure?action=getmeas&oauth_consumer_key=xxx...xxx&oauth_nonce=xxx...xxx&oauth_signature=xxx...xxx&oauth_signature_method=HMAC-SHA1&oauth_token=xxx...xxx&oauth_version=1.0&userid=nnn...nnn&oauth_timestamp=1234567890&startdate=$YESTERDAY&enddate=$NOW"
@valvallow
Copy link
Author

valvallow commented Dec 22, 2016

valvallow@callcc ~/dev/sh % ./get-withings-data.sh
{"status":0,"body":{"updatetime":1482418397,"measuregrps":[{"grpid":676178693,"attrib":0,"date":1482405304,"category":1,"measures":[{"value":62230,"type":91,"unit":-4}]},{"grpid":676178692,"attrib":8,"date":1482405304,"category":1,"measures":[{"value":66077,"type":91,"unit":-4}]},{"grpid":676178722,"attrib":0,"date":1482405290,"category":1,"measures":[{"value":65,"type":11,"unit":0}]},{"grpid":676178721,"attrib":0,"date":1482405290,"category":1,"measures":[{"value":58788,"type":1,"unit":-3},{"value":580,"type":8,"unit":-2},{"value":5032,"type":76,"unit":-2},{"value":3790,"type":77,"unit":-2},{"value":266,"type":88,"unit":-2},{"value":52988,"type":5,"unit":-3},{"value":9866,"type":6,"unit":-3},{"value":52982,"type":5,"unit":-3},{"value":9876,"type":6,"unit":-3}]},{"grpid":676178707,"attrib":0,"date":1482405256,"category":1,"measures":[{"value":58754,"type":1,"unit":-3},{"value":586,"type":8,"unit":-2},{"value":5022,"type":76,"unit":-2},{"value":3774,"type":77,"unit":-2},{"value":266,"type":88,"unit":-2},{"value":52894,"type":5,"unit":-3},{"value":9974,"type":6,"unit":-3},{"value":52882,"type":5,"unit":-3},{"value":9994,"type":6,"unit":-3}]},{"grpid":675809054,"attrib":0,"date":1482357371,"category":1,"measures":[{"value":58815,"type":91,"unit":-4}]},{"grpid":675809052,"attrib":8,"date":1482357371,"category":1,"measures":[{"value":67169,"type":91,"unit":-4}]},{"grpid":675809055,"attrib":0,"date":1482357359,"category":1,"measures":[{"value":98,"type":11,"unit":0}]},{"grpid":675809053,"attrib":0,"date":1482357359,"category":1,"measures":[{"value":59206,"type":1,"unit":-3},{"value":649,"type":8,"unit":-2},{"value":5005,"type":76,"unit":-2},{"value":3722,"type":77,"unit":-2},{"value":265,"type":88,"unit":-2},{"value":52716,"type":5,"unit":-3},{"value":10962,"type":6,"unit":-3},{"value":52706,"type":5,"unit":-3},{"value":10978,"type":6,"unit":-3}]}],"timezone":"Asia/Tokyo"}}%

@valvallow
Copy link
Author

valvallow commented Dec 22, 2016

valvallow@callcc ~/dev/sh % ./get-withings-data.sh | python -m json.tool
{
    "body": {
        "measuregrps": [
            {
                "attrib": 0, 
                "category": 1, 
                "date": 1482405304, 
                "grpid": 676178693, 
                "measures": [
                    {
                        "type": 91, 
                        "unit": -4, 
                        "value": 62230
                    }
                ]
            }, 
            {
                "attrib": 8, 
                "category": 1, 
                "date": 1482405304, 
                "grpid": 676178692, 
                "measures": [
                    {
                        "type": 91, 
                        "unit": -4, 
                        "value": 66077
                    }
                ]
            }, 
            {
                "attrib": 0, 
                "category": 1, 
                "date": 1482405290, 
                "grpid": 676178722, 
                "measures": [
                    {
                        "type": 11, 
                        "unit": 0, 
                        "value": 65
                    }
                ]
            }, 
            {
                "attrib": 0, 
                "category": 1, 
                "date": 1482405290, 
                "grpid": 676178721, 
                "measures": [
                    {
                        "type": 1, 
                        "unit": -3, 
                        "value": 58788
                    }, 
                    {
                        "type": 8, 
                        "unit": -2, 
                        "value": 580
                    }, 
                    {
                        "type": 76, 
                        "unit": -2, 
                        "value": 5032
                    }, 
                    {
                        "type": 77, 
                        "unit": -2, 
                        "value": 3790
                    }, 
                    {
                        "type": 88, 
                        "unit": -2, 
                        "value": 266
                    }, 
                    {
                        "type": 5, 
                        "unit": -3, 
                        "value": 52988
                    }, 
                    {
                        "type": 6, 
                        "unit": -3, 
                        "value": 9866
                    }, 
                    {
                        "type": 5, 
                        "unit": -3, 
                        "value": 52982
                    }, 
                    {
                        "type": 6, 
                        "unit": -3, 
                        "value": 9876
                    }
                ]
            }, 
            {
                "attrib": 0, 
                "category": 1, 
                "date": 1482405256, 
                "grpid": 676178707, 
                "measures": [
                    {
                        "type": 1, 
                        "unit": -3, 
                        "value": 58754
                    }, 
                    {
                        "type": 8, 
                        "unit": -2, 
                        "value": 586
                    }, 
                    {
                        "type": 76, 
                        "unit": -2, 
                        "value": 5022
                    }, 
                    {
                        "type": 77, 
                        "unit": -2, 
                        "value": 3774
                    }, 
                    {
                        "type": 88, 
                        "unit": -2, 
                        "value": 266
                    }, 
                    {
                        "type": 5, 
                        "unit": -3, 
                        "value": 52894
                    }, 
                    {
                        "type": 6, 
                        "unit": -3, 
                        "value": 9974
                    }, 
                    {
                        "type": 5, 
                        "unit": -3, 
                        "value": 52882
                    }, 
                    {
                        "type": 6, 
                        "unit": -3, 
                        "value": 9994
                    }
                ]
            }, 
            {
                "attrib": 0, 
                "category": 1, 
                "date": 1482357371, 
                "grpid": 675809054, 
                "measures": [
                    {
                        "type": 91, 
                        "unit": -4, 
                        "value": 58815
                    }
                ]
            }, 
            {
                "attrib": 8, 
                "category": 1, 
                "date": 1482357371, 
                "grpid": 675809052, 
                "measures": [
                    {
                        "type": 91, 
                        "unit": -4, 
                        "value": 67169
                    }
                ]
            }, 
            {
                "attrib": 0, 
                "category": 1, 
                "date": 1482357359, 
                "grpid": 675809055, 
                "measures": [
                    {
                        "type": 11, 
                        "unit": 0, 
                        "value": 98
                    }
                ]
            }, 
            {
                "attrib": 0, 
                "category": 1, 
                "date": 1482357359, 
                "grpid": 675809053, 
                "measures": [
                    {
                        "type": 1, 
                        "unit": -3, 
                        "value": 59206
                    }, 
                    {
                        "type": 8, 
                        "unit": -2, 
                        "value": 649
                    }, 
                    {
                        "type": 76, 
                        "unit": -2, 
                        "value": 5005
                    }, 
                    {
                        "type": 77, 
                        "unit": -2, 
                        "value": 3722
                    }, 
                    {
                        "type": 88, 
                        "unit": -2, 
                        "value": 265
                    }, 
                    {
                        "type": 5, 
                        "unit": -3, 
                        "value": 52716
                    }, 
                    {
                        "type": 6, 
                        "unit": -3, 
                        "value": 10962
                    }, 
                    {
                        "type": 5, 
                        "unit": -3, 
                        "value": 52706
                    }, 
                    {
                        "type": 6, 
                        "unit": -3, 
                        "value": 10978
                    }
                ]
            }
        ], 
        "timezone": "Asia/Tokyo", 
        "updatetime": 1482418863
    }, 
    "status": 0
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment