Skip to main content

Python client for the Lexicon DJ API

Project description

lexicon-python

A lightweight Python client for the Lexicon DJ API. It wraps the REST endpoints used for playlist browsing and track lookups, while staying simple enough to embed inside scripts or larger automation projects.

Features

  • Class LexiconClient with configurable host/port.
  • All GET requests for Playlists, Tracks, and Tags available
  • Handy helpers:
    • Interactive choose_playlist prompt for fast CLI workflows.
    • GET for all tracks can automatically retrieve all pages with get_all
    • Batch function get_track_batch can retrieve full metadata for a list of tracks (including progress bar for large retrievals)
  • Minimal dependencies (requests, tqdm) and a pure-Python implementation suitable for scripts or larger apps.

Quickstart

  1. Create a virtual environment and install requirements:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install -r requirements.txt
    
  2. Run the example script (ensure your Lexicon instance is reachable):

    python examples/demo_lexicon.py
    

    The script prompts you to choose a playlist, then fetches metadata for the first five tracks.

Usage

from lexicon import LexiconClient

lexicon = LexiconClient()

# Choose playlist interactively and fetch it's tracks
selection = lexicon.choose_playlist(show_counts=True)
if selection:
    path, playlist = selection
    print("Selected:", " / ".join(path))
    track_ids = set(playlist.get("trackIds", []))
    print("Tracks reported: ", len(track_ids))

    tracks = lexicon.get_track_batch(track_ids, max_workers=5)
    for track in tracks:
        print(track["title"], "-", track["artist"])
else:
    print("No playlist selected.")

# Fetch the complete library in chunks of 250
tracks = lexicon.get_tracks(limit=250, get_all=True) or []
print(f"Fetched {len(tracks)} tracks")

# Search within your library
results = lexicon.search_tracks({"artist": "Daft Punk", "bpm": ">=120"}) or []
print(f"Found {len(results)} matching tracks")

# Inspect tags and categories
tags_payload = lexicon.get_tags()
    if tags_payload:
        for category in tags_payload["categories"]:
            print("Category:", category["label"])
            for tag_id in category["tags"]:
                tag = next((t for t in tags_payload["tags"] if t["id"] == tag_id), None)
                print("->", tag["label"])

See examples/demo_lexicon.py for a more complete walkthrough.

Development

  • Run the test suite: PYTHONPATH=src python -m unittest discover -s tests
  • Style: keep the package pure Python, logging via logging.getLogger(__name__), and prefer small, testable helpers.
  • Packaging metadata lives in pyproject.toml (see below).

Contributions welcome—open an issue or PR with ideas!

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

lexicon_python-0.1.2.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

lexicon_python-0.1.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file lexicon_python-0.1.2.tar.gz.

File metadata

  • Download URL: lexicon_python-0.1.2.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lexicon_python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8c9bbc9479f095ae1c2ee8b041b19ebb898810e6413ffe48d163501f5aa88715
MD5 c4f16f08929bf7ab5bbba3dab7679123
BLAKE2b-256 7161b539b311fbac9a421b67ad242c3291bab86e0a034ade5779a7a2024c0a6b

See more details on using hashes here.

File details

Details for the file lexicon_python-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: lexicon_python-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lexicon_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2bc7b43ef3951c5a41685dae1795814cfd85cff7cc01eff03307336c4d79b7aa
MD5 60bd5e7596231757e9faeacda0bd0c21
BLAKE2b-256 d54e9a0cf9b8528efc60c362043242a3d6c89ae4c1bc206ccaf29f1274f98e60

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