Skip to main content

Traktor NML utils

Python package

This module contains utilities to parse and modify Native Instruments Traktor NML files.
Traktor 2.x, 3.x and 4.x NML files are supported.

It can parse collection NML files ($TRAKTOR_DIR/collection.nml) and history NML files ($TRAKTOR_DIR/History/history_$DATE.nml).

All NML attributes are readable and writable using auto-generated dataclasses (see traktor_nml_utils/models).
This allows a typesafe way to work with NML files, fully supporting IDE autocompletion:

alt text

While reading should work in 99% cases, writing NML files hasn't been tested thoroughly enough yet, so always keep a copy of your NML files.

Requirements

traktor-nml-utils requires Python 3.10 or newer.

traktor-nml-utils is tested with Traktor 4.x (NML VERSION="20") and Traktor 3.3.0, though it should be able to parse Traktor 2.x NML files as well. Feel free to provide files that cause problems on parsing.

Installation

pip install traktor-nml-utils

Usage

Get artist, title and rating of all collection entries

from traktor_nml_utils import TraktorCollection
from pathlib import Path

collection = TraktorCollection(path=Path('collection.nml'))

for entry in collection.nml.collection.entry:
    print(entry.artist, entry.title, entry.info.ranking)

Get cuepoint start

entry = collection.nml.collection.entry[0]

for cue_v2 in entry.cue_v2:
    print(cue_v2.start)

Find entry

artist = "Yotto"
title = "Another Riff For The Good Times (Extended Mix)"

entry = [
    entry for entry in collection.nml.collection.entry
    if entry.artist == artist
    and entry.title == title
][0]

Add cuepoint

from traktor_nml_utils.models.collection import CueV2Type
from traktor_nml_utils.utils import duration_str_to_milliseconds

my_cue = CueV2Type(
    value=None, 
    name='n.n.', 
    displ_order=0, 
    type=0, 
    start=duration_str_to_milliseconds("00:01:00"), 
    len=0.0, 
    repeats=-1, 
    hotcue=1
)
entry.cue_v2.append(my_cue)

# Write XML file
collection.save()

Run tests

Run tests within Docker container:

argc docker-build
argc docker-test

Create virtualenv and run tests:

argc virtualenv-create
argc virtualenv-test

To test if parsing your own collection/history files with traktor-nml-utils works, pass your Traktor directory to the CLI:

traktor-nml-utils traktor-import ~/traktor3/

How does it work?

NML files to Python dataclasses

Since there is no official schema for Traktor NML files, the dataclasses in traktor_nml_utils/models/ were generated from sample NML files with xsdata, which infers the schema directly from XML documents. They have since been hand-tuned to match Traktor's exact output format, so they are maintained in the repository rather than regenerated blindly.

To generate fresh models from your own files, overwrite collection.nml and history.nml in ./xml_to_xsd/ and run:

argc generate-models

This writes new models to build/generated/. Compare them against the hand-tuned modules in traktor_nml_utils/models/ and merge any differences manually (class names differ: xsdata names classes after elements, e.g. Entry instead of the committed Entrytype).

Contribution

Help wanted!

Since the XSD-schema was created from my own Traktor files, the schema might not fit for all collection and history files. In case you have any problems parsing NML files, please report an issue and attach the problematic NML file so I can update the schema.

Metadata

Release files for traktor-nml-utils 4.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traktor-nml-utils 4.1.0
File Size Uploaded
traktor_nml_utils-4.1.0.tar.gz 27.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for traktor-nml-utils 4.1.0
File Interpreter ABI Platform
traktor_nml_utils-4.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.5 kB

Release files / traktor_nml_utils-4.1.0.tar.gz

Download URL traktor_nml_utils-4.1.0.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6f9c4e586651afe96c5bb9a042ed87e678d501b580e5552bfb53bc40aab78d03
BLAKE2b-256 checksum
How to use checksums
15643ff077ba741990fe26576f7dd809878ea6adbca606a3b2fbc7b918a2ac78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.

Transparency log

Release files / traktor_nml_utils-4.1.0-py3-none-any.whl

Download URL traktor_nml_utils-4.1.0-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0a6bb8a419f0ec4a75ef84f9af04ae8b952b2f57044dce7c16188acbbb9f504
BLAKE2b-256 checksum
How to use checksums
d95a7728c6e6ba2fb37bcd9b1d040ba6c77d15241cddc06b3c12472fa18c9042
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

4.1.0 This release

2 release files

4.0.0

2 release files

3.1.0

1 release file

3.0.2

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.0.6

1 release file

2.0.5

1 release file

2.0.4

1 release file

1.0.2

1 release file

1.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page