Package: whoopy
Whoop Python ClientThis is an unofficial implementation of theofficial Whoop API.Getting StartedFirst you will need to install the library:# either from pypipipinstallwhoopy# or by local buildpipinstall.In order to use the API, you will need to register your applicationhereand
enter theclient_id,client_secretandredirect_uriin theconfig.jsonfile (you can use the template provided inconfig.sample.json):{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET","redirect_uri":"YOUR_REDIRECT_URI"}Note: For the purposes of local use, you can simply providehttp://localhost:1234as redirect_uri in the app registrationAuthorizationYou can then the config to run through the client authentication and save the token:importjsonfromwhoopyimportWhoopClient# load the configconf=json.load(open("config.json","r"))# either run through full auth process (useful in jupyter notebooks)# note: This will open the web browser and require you to copy the code parameter from the resulting uri backclient=WhoopClient.auth_flow(conf["client_id"],conf["client_secret"],conf["redirect_uri"])# or run through the steps manually (useful in backend)url=WhoopClient.auth_url(conf["client_id"],conf["client_secret"],conf["redirect_uri"])# (open here or run a redirect on your backend)webbrowser.open(url)# retrieve codecode=input("Auth Code")client=WhoopClient.authorize(code,conf["client_id"],conf["client_secret"],conf["redirect_uri"])The code can be copied from the address in the browser (marked in bold):http://localhost:1234/?code=j54Y9X...m4&scope=offline%20read...&state=9f..05NoteIf you want to know more about this, seeOAuth FlowsYou can also provide ascopeargument to limit what your client can read.The system also allows to store, load and refresh your token (given that theofflinescope is set):# store the tokenclient.store_token(".tokens/token.json")# load the tokenclient_new=WhoopClient.from_token(".tokens/token.json",config["client_id"],config["client_secret"])# refresh the current tokenclient.refresh()Data RetrievalOnce you have the client registered you can retrieve the data through the different sub-functions:# user infouser_data=client.user.profile()print(f"Name:{user_data.first_name}{user_data.last_name}")# other data includes recovery, workout, cycle, sleep (all share the same interface)# retrieve by single iditem=client.cycle.single("1234")# this retrieves a list of itemsitems,_=client.cycle.collection(start="2022-05-10",end="2022-07-03")# note: whoop paginates these items - if you want to control the page yourself you can use the tokenitems1,token=client.cycle.collection(start="2022-05-10",end="2022-07-03",get_all_pages=False)items2,token=client.cycle.collection(start="2022-05-10",end="2022-07-03",next=token,get_all_pages=False)# retrieve data as pandas dataframedf,_=client.cycle.collection_df(start="2022-05-10",end="2022-07-03")For a full description of the available routes, seeofficial docs.ToolsThe repo also contains a dashboard to explore and download your whoop data using streamlit.To get started, simply install the requirements in thetools/explorerfolder:pipinstall-rrequirements.txtThen run the streamlit app:streamlitrunexplorer.pyThis should give you the dashboard:It also allows you to download your data directly: