Skip to main content

Unofficial Python API for the Light Phone

Project description

Light API/CLI/TUI

An unofficial, community-maintained API and CLI/TUI for managing music, notes, podcasts, and tools on Light devices.

This was made by reverse-engineering the API endpoints from the official dashboard. (I have obtained Light's blessing for this.)

[!CAUTION] This is beta software and is actively in development. Bugs are expected, and bug reports are welcome!

[!WARNING] Because this is an unofficial set of tools created through reverse-engineering, this could break at any time if Light decides to change the structure of their API.

Installation

This repo bundles two separate packages light-api and light-cli-tui. Install whichever suits your needs.

From PyPI:

pip install light-phone-api
pip install light-phone-cli-tui

Nix users:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    light.url = "github:garado/light";
  };

  outputs = { nixpkgs, light, ... }: {
    nixosConfigurations.YOURHOST = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        ({ pkgs, ... }: {
          environment.systemPackages = [
            light.packages.x86_64-linux.light-cli-tui
            light.packages.x86_64-linux.light-api
          ]
        }
      ];
    };
  };
}

Authentication

This needs your Light email, password, and phone number to authenticate into the Light dashboard and operate on the correct device.

Three options:

# 1. Environment variable
# Assuming LIGHT_EMAIL, LIGHT_PASSWORD, LIGHT_PHONE_NUMBER are set (see .env.example)
light <command>

# 2. Command line
light --email=... --password=... --phone-number=... <command>

# 3. File
light --email-file=... --password-file=... --phone-number-file=... <command>

After the first login, your auth token will be cached. Tokens are good for 30 days.

Getting started: CLI/TUI

Note: As is the case with the official Light dashboard, any changes made through these tools may take a few moments to propagate to the device.

Music

Upload

# Upload tracks
# Overwrite existing matching tracks (match on file title metadata)
light music upload song1 song2 song3 --match-title-by metadata

# Upload tracks
# Overwrite existing matching tracks (match on filename)
light music upload song1 song2 song3 --match-title-by filename

# Upload tracks
# Don't overwrite existing tracks
light music upload --allow-duplicates song1 song2 song3

Delete

# Delete tracks
light music delete song

# Delete all tracks (multiple confirmation steps, don't worry)
light music delete-all

Sort

# Sort tracks by title (!!!)
light music sort title --asc
light music sort title --desc

# Sort tracks by artist
light music sort artist --asc
light music sort artist --desc

# Sort tracks by artist and album (!!!)
# (Track numbers not supported)
light music sort artist-album --asc
light music sort artist-album --desc

Notes

# List all notes (with optional content preview)
light notes list
light notes list --content-preview

# List notes with file IDs (needed for `watch` cmd)
light notes list --id

# Create a new text note
light notes add "Shopping list" "eggs, milk, bread"
light notes add "Meeting notes" --file notes.txt  # copy contents from notes.txt

# Download all notes to a directory
# Text notes saved as .txt, audio notes as .m4a
light notes download ~/my-notes

# Watch a note for changes (polls every 5s, prints when updated_at changes)
# Useful for more advanced custom integrations (happy hacking!)
light notes watch <note-id>

Podcasts

# Subscribe to a podcast by RSS feed URL
light podcast add https://feeds.simplecast.com/FO6kxYGj

# List followed podcasts
light podcast list

# Unfollow a podcast by title
light podcast delete "My Podcast"

Tools

Available tools: alarm album calculator calendar camera directions directory hotspot music notes podcasts timer

light tools list

light tools add <tool>

light tools remove <tool>

TUI

The TUI offers an easier way of managing music and notes.

# Launch
light tui

TUI-specific features:

  • First-class support for Vim bindings
  • Music
    • Reorder tracks individually or in visual block mode
    • Bulk edit track metadata
    • Bulk delete tracks
  • Notes
    • Content preview for both text and audio notes
    • Press e to edit in $EDITOR

Music

Key Action
j / k Navigate
gg / G Jump to top / bottom
J / K Move track up / down
5J / 5K Move track up / down by 5
v Enter visual mode (select a block)
J / K in visual Move selected block up / down
gg / G in visual Move selected block to top / bottom
d in visual Delete selected tracks
e Edit track metadata
e in visual Bulk edit metadata (shared fields pre-filled)
s Cycle sort mode
/ Search
r Refresh

Notes

Key Action
j / k Navigate
gg / G Jump to top / bottom
Enter Load note content
n New note (opens in $EDITOR)
e Edit note content in $EDITOR
R Rename note
dd Delete note (with confirmation)
y Copy content to clipboard
p Play / stop audio note
r Refresh

Screenshots

image image

Getting started: API

Minimal API usage examples are in examples/.

Tests

Unit tests

Unit tests use request playback with respx.

# This will populate `tests/fixtures/` with the response JSON to test against
python scripts/capture_fixture.py

# Run tests
uv run pytest

Smoke tests (TODO)

As this is an unofficial tool, it could break at any time if Light changes the API format. Smoke tests should be added and run regularly (home server nightly cronjob?) to catch any breaking API changes asap.

Developer stuff

Regenerate API from spec

The source of truth is the OpenAPI JSON. Python API bindings are automatically generated from that JSON using openapi-python-client.

cd light_api
openapi-python-client generate --path openapi-spec.json
# this will generate open-api-specification-client (kebab case)
# delete the existing open_api_specification_client contents and copy the kebab-case dir contents to the snake-case dir

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

light_phone_api-0.1.1.tar.gz (75.6 kB view details)

Uploaded Source

Built Distribution

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

light_phone_api-0.1.1-py3-none-any.whl (298.0 kB view details)

Uploaded Python 3

File details

Details for the file light_phone_api-0.1.1.tar.gz.

File metadata

  • Download URL: light_phone_api-0.1.1.tar.gz
  • Upload date:
  • Size: 75.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for light_phone_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 558e31dbe6f5c2dbe7b3d92e5e407a1e22176755693ff5a653cfed2406f5a501
MD5 baa18833079bfa1f8e1f946b15911647
BLAKE2b-256 8ac1eb6170cf0fec51dc9f56f51a582ce3b58d7f9699aa9e407b76e84c904152

See more details on using hashes here.

File details

Details for the file light_phone_api-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: light_phone_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 298.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for light_phone_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e56049d3f3e989e2b2ca38d21b307e1eaa65d8f31f5602b9f0b2ba3d0da1a29c
MD5 d26581639ce84b245f3442eacdad1834
BLAKE2b-256 5e56ea6f0ec8c7d2b5831d178c3e0b2a19f5ad8a66faee856bc850239ca57649

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