Skip to main content

This script retrieves the Bluetooth access token for the watch or band from Huami servers. Additionally, it downloads the AGPS data packs, cep_alm_pak.zip and cep_7days.zip.

Project description

Huami-token is now hosted on codeberg.org.

Get it on Codeberg

Huami-token

status-badge

Script to obtain watch or band bluetooth access token from Zepp (Amazfit) or Xiaomi Mi Fitness servers.

About

To use new versions of Amazfit and Xiaomi watches and bands with Gadgetbridge you need special unique key. Read more here: https://gadgetbridge.org/basics/pairing/huami-xiaomi-server/.

Community

If you would like to get in touch

Installation

From PyPI (currently outdated)

pip install huami-token

From source

  1. Ensure that you can login in the Zepp App with e-mail and password. If not, create new Amazfit account with e-mail and password.
  2. Pair, sync and update your watch with Zepp App. Your pairing key will be stored on Huami servers.
  3. Install uv: https://docs.astral.sh/uv/getting-started/installation/
  4. Clone this repo and cd into it.
  5. Install the package: uv pip install -e ".[dev]"

Usage

After installation, the huami-token command is available:

usage: huami-token [-h] -m {amazfit,xiaomi} [-e EMAIL] [-p PASSWORD] [-b] [-g] [-n]

Obtain Bluetooth Auth key from Amazfit (Zepp) or Xiaomi Mi Fitness.

options:
  -h, --help            show this help message and exit
  -m {amazfit,xiaomi}, --method {amazfit,xiaomi}
                        Login method. Chose Amazfit for Zepp.
  -e EMAIL, --email EMAIL
                        Account e-mail address
  -p PASSWORD, --password PASSWORD
                        Account Password
  -b, --bt_keys         Get bluetooth tokens of paired devices
  -g, --gps             Download GPS files (AGPS_ALM, AGPSZIP, LLE, etc.)
  -n, --no_logout       Do not logout, keep active session and display app token and access token

You can also run directly via python main.py if you prefer not to install.

Logging in with Amazfit account

Run with your credentials:

huami-token --method amazfit --email your_email@example.com --password your_password --bt_keys

Sample output:

2025-11-14 18:41:43.316 | INFO     | huami_token.zepp:login:67 - Logging in...
2025-11-14 18:41:44.268 | INFO     | huami_token.zepp:_get_refresh_and_access_tokens:120 - Received access and refresh tokens successfully
2025-11-14 18:41:45.217 | INFO     | huami_token.zepp:login:70 - Logged in! User id: 1234567890
2025-11-14 18:41:45.217 | INFO     | huami_token.zepp:get_devices:187 - Getting linked devices...
Device 0:
  MAC: AB:CD:EF:12:34:56, Active: Yes
  Key: 0xa3c10e34e5c14637eea6b9efc06106
2025-11-14 18:41:46.400 | INFO     | huami_token.zepp:logout:178 - Logged out.

Logged out.

Here the Key is the unique pairing key for your watch. The Active tab shows whether a device is active or not.

Logging in with Xiaomi account

huami-token --method xiaomi --email your_email@example.com --password your_password --bt_keys

Sample output:

2025-11-14 18:41:43.316 | INFO     | huami_token.xiaomi:login:81 - Logging in to Xiaomi...
2025-11-14 18:41:44.268 | INFO     | huami_token.xiaomi:login:85 - Logged in! User id: 1234567890
Device 0: Amazfit Band 7
  MAC: AB:CD:EF:12:34:56
  Key: 0xa3c10e34e5c14637eea6b9efc06106

Logged in successfully.
user_id=1234567890

Note: GPS download (--gps) is not yet supported for Xiaomi accounts.

AGPS

This script can download AGPS files (requires login):

huami-token --method amazfit --email your_email@example.com --password your_password --gps

The following files are downloaded:

  • AGPS_ALM -- cep_1week.zip
  • AGPSZIP -- cep_7days.zip
  • LLE -- lle_1week.zip
  • AGPS -- cep_pak.bin
  • EPO -- EPO.ZIP
  • LTO -- LTO data file

Development

uv pip install -e ".[dev]"

# Run tests
pytest -m "not integration"

# Lint
ruff check .

# Type check
mypy huami_token/

# Build wheel
uv build

Dependencies

  • Python >= 3.10
  • requests
  • loguru
  • pycryptodome

License

This project is licensed under the MIT License - see the LICENSE.md file for details

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

huami_token-0.8.0.tar.gz (40.7 kB view details)

Uploaded Source

Built Distribution

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

huami_token-0.8.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file huami_token-0.8.0.tar.gz.

File metadata

  • Download URL: huami_token-0.8.0.tar.gz
  • Upload date:
  • Size: 40.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for huami_token-0.8.0.tar.gz
Algorithm Hash digest
SHA256 cf30099e25e840d875b8d17a6c06811c6e6b7f6af6cba4b8016ec9d82de2c1f1
MD5 26382ccebd401b923630b1e85c42ac6f
BLAKE2b-256 a72ffc53218a41c278208263fe9fb253a74a431b664ed160eac2bd05643ca449

See more details on using hashes here.

File details

Details for the file huami_token-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: huami_token-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for huami_token-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 670e8abe27e69b6ebd63266b7c505c88bdb28c815b222f4cace33ea5bb013841
MD5 599cd35088be73e700b53b6c176bddad
BLAKE2b-256 d4b5af36da072ed231368ee2d1f05e7144ca4dd7bd4ab10dfa8f8e3bade98ea9

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