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, a move format used by Chess.com. 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.1.tar.gz (4.3 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.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chess_tcn-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 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.1.tar.gz
Algorithm Hash digest
SHA256 780753b0890ec5f7676313457545117bbd44fe625ce468017d2fe4f57653f7e7
MD5 4942295885a06e0e27eb334d21e80eae
BLAKE2b-256 9e6df299620e9fec7a4c57ac705cb5778a5bbf99fa6f8e564be6967b2007e6f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chess_tcn-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e087745dbb30fbcfd9a4c9ecdbd68e8065a16d4c6455a7edf5dbe58c2bb20001
MD5 34b73baed1c863fdb1008991c6545c2a
BLAKE2b-256 a83282d3f8e387e37032779d106b051d484e2b0cb24d7f289ce6a1f6822c77f0

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