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_pgn

# Decode TCN to PGN
tcn_string = 'mC0Kgv7Tbq5Qlt9IqHT7cM1TMFWOHs2MFwZRfm6Eeg'
pgn = decode_tcn(tcn_string)
print(pgn)

# Encode PGN back to TCN
new_tcn_string = encode_pgn(pgn)
print(new_tcn_string)

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-0.0.1.tar.gz (2.5 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-0.0.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for chess_tcn-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f9b2944696b483142a647d64e52dbfc0075dfe98f42f20ff89e09649aaa20c54
MD5 99e3426de12872e629592b6529e3e8fa
BLAKE2b-256 e65f1bf13b9c08e9fd22a1993cf591f5393b05a2d6ecd344af987b45a6af785b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chess_tcn-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 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-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d0d6e48a00f5752a28d694cb1b2a16c813d386341165f18175a0695baaefe70c
MD5 ccf1ced85025ef9f72a6b7e281f4a34d
BLAKE2b-256 c02f5244f291180ca8b6f315b2afd736d89fa6eeb0209e67a30ea99e4019cb72

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