Skip to main content

Zwift data explorations.

Project description

logo

zwi

Here are some small python programmes to facilitate viewing Zwift data.

requirements

a Zwift user account
python3.9 or later
pip3

usage

The easiest way to use this is to use pip3 install to install everything you need. Prior to that, you should probably have done something like:

ZWI_ENV=/tmp/zwi_env
python3 --version
python3 -m venv ${ZWI_ENV}
. ${ZWI_ENV}/bin/activate

If using anaconda:

conda create -n zwi python=3.9
conda activate zwi

At this point, you will have a dedicated play area to install zwi and dependencies.

pip3 install zwi

This will install everything required, and place two command scripts in ${ZWI_ENV}/bin which will be in your ${PATH} while the environment is activated.

zwi --help

version

zwi version

The version function returns the version number of the currently installed zwi package.

authentication

Before you can do much of interest, you must store your authentication information in the local key store. For OsX, this is the system keychain. For Linux, it is something similar.

zwi auth --help
zwi auth --name=guest@example.com --password=SuperSecret123
zwi auth

You can have the auth programme prompt for both name and password. You need to enter the password twice, in that case, and it will not be stored unless it successfully authenticates with the Zwift server.

verification

zwi check --help
zwi check

The check function will verify that the stored credentials function. At times on MacOS, the keychain decides it doesn't like you any more and requires you to enter your login password, twice, whenever zwi access the stored user name and password. Make sure you click on always allow unless you need to practice typing your password.

initialise/reset database

Once you are authenticated, the next step is to populate the local database cache with information from Zwift. zwi maintains state in ${HOME}/.zwi/. An sqlite3 database is used to cache the state of the user's followers and followees lists. In addition, the profiles of all Zwift users encountered (via the followers/followees lists) are saved in a separate database.

zwi reset --help
zwi reset

The reset function deletes the ${HOME}/.zwi/zwi.db database file if it exists, creates the sqlite3 database, and populates the database with the followers and followees tables. It will not delete the profiles database, but it will ensure that there are profile entries for each user in the followers and followees lists.

update followers/followees database

zwi update --help
zwi -v update

The update function refreshes the followers and followees information. (Currently, this function is being fleshed out. It does not yet report any differences. Also, it fails to process deletions.)

update profile database

zwi pro-update --help
zwi [-v] pro-update [--force]

The pro-update function will update the local DB profile cache using information in the local Zwift user followers and followees DB cache.

list profile database entries

zwi pro-list --help
zwi pro-list

The profiles list can be displayed.

bokeh

zwibok serve [--port=#]

The profile database can be viewed using the zwibok app. This will pop up a page on your browser allowing you to explore various attributes of the users in the profile data base. It should be more or less obvious. Eventually I might try to write some usage info, but as it is more or less a proof-of-concept, it might change again soon.

Basically, it presents an X/Y plot of subsets of the data. You can select different data columns for X and Y. You can adjust range sliders to reduce the set of data points in the plot. Male-only or female-only or both can be selected.

The cross-hairs of the cursor select users and display some more info pertaining to the user.

gui

zwi gui --help
zwi gui

The gui function pops up a window displaying data from the local database copy of the Zwift followers and followees tables. This was my second attempt at writing a gui to view some of the data. Currently, it only displays information from the followers and followees lists.

Key Bindings (for OSX):

CMD-1  Switch to `followers` table.
CMD-2  Switch to `followees` table.
CMD-a  Toggle `auto` mode.
CMD-n  Move to next entry.
CMD-p  Move to previous entry.
CMD-f  Search (not yet implemented).
CMD-q  Quit

If auto mode is enabled:

CMD-n  increase interval
CMD-p  decrease interval

The slider at the bottom can be used to move rapidly thru the list.

For Linux, it appears the key bindings map to the CTRL key. The menu items will indicate whatever it is.

followees

zwi wees --help
zwi wees

The wees function will check the cached followees list (them who's followed). Any subject who is being followed but who is not reciprocating is displayed. You will have to manually search for the user in the Zwift companion and decide what punishment to hand out.

followers

zwi wers --help
zwi wers

The wers function will check the cached followers list and display any lacking reciprocity. Certain users will follow you, but not respond to reciprocal follow requests, remaining forever in limbo. One can always try unfollowing/refollowing to see if the recalcitrant is interested in reciprocity. As above, as far as I know, one has to use the Zwift companion app to search by name.

inspect other user's public information.

Per the Zwift privacy policy, various data are publicly accessible. The inspect command facilitates examination of the publicly available data.

zwi inspect --help
zwi inspect --zid=ZwiftUser
zwi -v inspect --zid=ZwiftUser --update

removing authentication information

The clear function will remove any cached user/password information from the key-store.

worlds

The worlds function will show how many users are signed in currently.

zwi worlds --help
zwi -v worlds
zwi worlds --poll

development

I have been using anaconda on OsX for development. Supposedly, this will install things to facilitate development:

conda env create -f environment.yml
conda activate zwi
flit install --symlink
pip3 install zwift-client
pip3 install PyQt5

hints

When manually deleting followees, using the Zwift companion app, and searching by name, I find it helps to type in the bits of the name which are more likely to be unique, so as to limit the lists presented.

user feedback

issues

If you have any problems with or questions about this image, please contact me through a GitHub issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zwi-0.3a2.dev2.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zwi-0.3a2.dev2-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

Details for the file zwi-0.3a2.dev2.tar.gz.

File metadata

  • Download URL: zwi-0.3a2.dev2.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.26.0

File hashes

Hashes for zwi-0.3a2.dev2.tar.gz
Algorithm Hash digest
SHA256 be70b06dfd488241f387b78aef4dc32f4f0ed172c11a35cf6dfdd0aa9a65764c
MD5 4175df9019453e95d2002a977b617357
BLAKE2b-256 e8fd71823e86a239e75f0f173a9f33ee3f992a9aa20f2a32785559f00e62ea35

See more details on using hashes here.

File details

Details for the file zwi-0.3a2.dev2-py3-none-any.whl.

File metadata

  • Download URL: zwi-0.3a2.dev2-py3-none-any.whl
  • Upload date:
  • Size: 33.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.26.0

File hashes

Hashes for zwi-0.3a2.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 8848aeaf774ba273df4146dea62df07ef4ca45f2488ba878810116682b413295
MD5 adba804b7792418a8d698b2fc95c5b7b
BLAKE2b-256 b91b3b8bd02c59b629f4f0f27747c50490d7b4755903709d0652fa79ad7077df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page