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.1.tar.gz (13.9 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.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lexicon_python-0.1.1.tar.gz
  • Upload date:
  • Size: 13.9 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.1.tar.gz
Algorithm Hash digest
SHA256 d74e67cf053ab953328493902bb8fcd2ac8b0f78b7064f8a386cd088bc03e5a5
MD5 77f8e2f64502e6f5e4401abe92269cc2
BLAKE2b-256 e39ebd4000515c099939a23391294370ef52c64faca8cdfc8eb87f854f43c53b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lexicon_python-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cce02d2dc8275837491ed17f08e489e2c8830534fa1999fb55d9ca27a2ed8740
MD5 67def1f55636152a178278a3c29f02b0
BLAKE2b-256 b81c593686548e325a7d86638579e02b15fdb18b18469fdd0e4f1629a3a6483a

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