Skip to main content

Encode and decode TCN, a move format used by Chess.com's API

Project description

Chess TCN Python

Overview

Chess TCN Python is a Python package that provides functionality to encode and decode TCN (Tournament Chess Notation), a move format used by Chess.com's live-game API. This package is ideal for developers looking to work with TCN in Python applications.

What is TCN?

TCN is a format used by Chess.com to transmit move lists in its JSON API. A typical endpoint for retrieving a game’s move list is:

https://www.chess.com/callback/live/game/{gameId}

This endpoint returns a moveList field containing a TCN string.

Features

  • Decode TCN strings into PGN (Portable Game Notation).
  • Encode PGN back into TCN format.

Installation

To install the package, use pip:

pip install chess-tcn

Usage

Here’s a quick example of how to use the package:

from chess_tcn import decode_tcn, encode_tcn, tcn_to_pgn, pgn_to_tcn

# Example TCN string (e.g. from Chess.com live‐game API)
tcn_string = "mC0Kgv7Tbq5Qlt9IqHT7cM1TMFWOHs2MFwZRfm6Eeg"

# Decode TCN to a list of move dicts
moves = decode_tcn(tcn_string)
print("Decoded moves (dicts):", moves)

# Re-encode that move list back into a TCN string
reencoded_tcn = encode_tcn(moves)
print("Re-encoded TCN string:", reencoded_tcn)

# Convert the TCN string directly to a PGN move-text string
pgn_text = tcn_to_pgn(tcn_string)
print("PGN move-text:", pgn_text)

# Convert a PGN move-text string back into TCN
roundtrip_tcn = pgn_to_tcn(pgn_text)
print("TCN from PGN:", roundtrip_tcn)

API Reference

For complete details on usage, check out the documentation.

License

This project is licensed under the MIT License. See below for full text.

MIT License

Copyright (c) 2021-2025 chess-tcn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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

chess_tcn-1.0.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

chess_tcn-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file chess_tcn-1.0.0.tar.gz.

File metadata

  • Download URL: chess_tcn-1.0.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for chess_tcn-1.0.0.tar.gz
Algorithm Hash digest
SHA256 55110fa7ebac6b535f2a27ea8ab6f79e21ccedb218059e7436fa659b9935ab81
MD5 dec76d839616f0c476f3b0387142e402
BLAKE2b-256 0c086eb452e613b4670fb399550e2358ff5dc64e81a99a38814c509dc1fd8abf

See more details on using hashes here.

File details

Details for the file chess_tcn-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: chess_tcn-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for chess_tcn-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bfe81a1ac8d4698fda96828af3bb4dbf55b8893370c60f9382ef691c91169b5
MD5 ed832253c2e9a7900bfe1891f25f8f9b
BLAKE2b-256 c062186cc80faf646e90aaa49d1fdf1a4ab803ae801248be91845fe7382f9607

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