A simple chess openings (ECO) library for Python.
Project description
Openix
A Python chess openings library for loading, searching, and exploring ECO opening lines.
Why Openix
Openix gives you a ready-to-use chess openings library with bundled ECO data, simple search tools, and a clean API for Python projects that need opening lookup, move suggestions, or opening exploration.
- Load bundled opening files directly from the package.
- Search by ECO code, opening name, move prefix, or partial move sequence.
- Handle castling written as
O-Oor0-0. - Work with
python-chessboards after applying an opening line. - Use lightweight methods without extra setup beyond installation.
What's New in 2.0.4
- Added
load_builtin_openings()for loading bundled ECO JSON data directly. - Fixed parsing for move strings like
1.a3. - Normalized castling formats such as
0-0and0-0-0. - Made
find_by_eco()case-insensitive. - Improved package metadata and packaging for cleaner publishing.
- Refreshed the documentation and project presentation.
Installation
pip install Openix
Quick Start
from Openix import ChessOpeningsLibrary, __version__
print(__version__) # 2.0.4
library = ChessOpeningsLibrary()
library.load_builtin_openings()
results = library.find_openings_after_moves(["e4", "e5", "Nf3", "Nc6", "Bb5"])
for opening in results[:3]:
print(opening.eco_code, opening.name)
print(opening.moves_list)
Common Use Cases
Load bundled openings
from Openix import ChessOpeningsLibrary
library = ChessOpeningsLibrary()
loaded_count = library.load_builtin_openings()
print("Loaded:", loaded_count)
print("Total:", len(library.get_all_openings()))
Search by ECO code
library.find_by_eco("C50")
library.find_by_eco("c50") # same result
Search by name
matches = library.search_by_name("sicilian")
for opening in matches[:5]:
print(opening.eco_code, opening.name)
Find openings after a move sequence
results = library.find_openings_after_moves(
["e4", "e5", "Nf3", "Nc6", "Bc4", "Bc5", "0-0"]
)
Get the most common next moves
next_moves = library.list_next_moves_after(["e4", "e5", "Nf3", "Nc6"])
print(next_moves[:5])
Build a board from an opening
from Openix import ChessOpening
opening = ChessOpening(
"C60",
"Ruy Lopez",
"1. e4 e5 2. Nf3 Nc6 3. Bb5"
)
board = opening.get_board_after_opening()
print(board)
Loading Custom JSON Files
You can load your own opening files in addition to the bundled dataset.
from Openix import ChessOpeningsLibrary
library = ChessOpeningsLibrary()
library.load_from_json_file("my_openings.json")
library.load_multiple_files(["ecoA.json", "ecoB.json"])
Each opening entry should follow this structure:
{
"eco": "C60",
"name": "Ruy Lopez",
"moves": "1. e4 e5 2. Nf3 Nc6 3. Bb5"
}
API Overview
ChessOpening
Represents a single opening line.
Useful attributes:
eco_codenamemoves_strmoves_listlast_movemoves_count
Useful methods:
get_board_after_opening()from_dict(data)
ChessOpeningsLibrary
Loads and searches many openings.
Loading methods:
load_builtin_openings(raise_on_error=False)load_from_json_file(file_path, raise_on_error=False)load_multiple_files(files_list, raise_on_error=False)
Search methods:
find_by_eco(eco_code)search_by_name(name_substring)find_openings_starting_with(move_san)find_openings_after_moves(moves_list)list_openings_after_moves(moves_list)list_next_moves_after(moves_list)search_by_partial_moves(moves_sublist)
Utility methods:
get_random_opening()get_random_opening_starting_with(move_san)get_random_opening_after_moves(moves_list)get_all_openings()get_statistics()
Notes
- Move strings should be valid SAN sequences.
- Invalid entries are skipped during loading unless
raise_on_error=True. - The package depends on
python-chess. - Bundled ECO data is included with the package.
Changelog
See CHANGELOG.md for release notes.
License
This project is released under the MIT License. See LICENSE.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openix-2.0.4.tar.gz.
File metadata
- Download URL: openix-2.0.4.tar.gz
- Upload date:
- Size: 327.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
436e580f6916ebcfacac26974b33b15ca4c3c914dde847fa5d551618f0c7aafe
|
|
| MD5 |
7a0764fa0a6947acc781f1397d218c8c
|
|
| BLAKE2b-256 |
fa95a1c941c569cb564ad22bc1a21757f2aaebb4f0d0549771140076467c242c
|
File details
Details for the file openix-2.0.4-py3-none-any.whl.
File metadata
- Download URL: openix-2.0.4-py3-none-any.whl
- Upload date:
- Size: 345.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28b3468388258581248d33f90757a6eb27bd618f7dfe319b7cc4fa771bd707fa
|
|
| MD5 |
fa6892501be3fafd9d361ec1e9bce293
|
|
| BLAKE2b-256 |
b92f142a12d5da10da57fbcd3aa22d0cc3015d16036f7b3cb65485d5bbcf0991
|