https://github.com/shahradelahi/node-stockfish
♟️ Stockfish 17.1 WASM chess engine for Node.js with UCI and analysis.
https://github.com/shahradelahi/node-stockfish
analysis chess engine fen nodejs stockfish typescript uci wasm
Last synced: 5 months ago
JSON representation
♟️ Stockfish 17.1 WASM chess engine for Node.js with UCI and analysis.
- Host: GitHub
- URL: https://github.com/shahradelahi/node-stockfish
- Owner: shahradelahi
- License: mit
- Created: 2025-12-25T13:43:13.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-12-29T15:47:07.000Z (6 months ago)
- Last Synced: 2026-01-01T19:42:00.284Z (6 months ago)
- Topics: analysis, chess, engine, fen, nodejs, stockfish, typescript, uci, wasm
- Language: JavaScript
- Homepage: https://npmjs.com/@se-oss/stockfish
- Size: 60.1 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Stockfish for Node.JS
_@se-oss/stockfish_ is a high-performance, TypeScript-first Node.js wrapper for the Stockfish 17.1 WASM chess engine. It provides a convenient API for integrating powerful chess analysis capabilities into your applications, offering functionalities such as position analysis, best move calculation, and direct UCI command interaction.
---
- [Installation](#-installation)
- [Usage](#-usage)
- [Documentation](#-documentation)
- [Contributing](#-contributing)
- [License](#license)
## 📦 Installation
```bash
npm i @se-oss/stockfish
```
Install using your favorite package manager
**pnpm**
```bash
pnpm install @se-oss/stockfish
```
**yarn**
```bash
yarn add @se-oss/stockfish
```
## 📖 Usage
### Basic Analysis
```typescript
import { Stockfish } from '@se-oss/stockfish';
const engine = new Stockfish();
await engine.waitReady();
const analysis = await engine.analyze(
'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
15
);
console.log('Best move:', analysis.bestmove); // e2e4
console.log('Score:', analysis.lines[0].score); // { type: 'cp', value: 39 }
```
### Advanced UCI Commands
```typescript
const engine = new Stockfish();
engine.on('info', (info) => {
console.log(`Depth ${info.depth}: ${info.pv}`);
});
await engine.send('uci');
await engine.send('isready');
await engine.send('position startpos moves e2e4');
await engine.send('go depth 20');
```
### Using the Stockfish Pool
```typescript
import { StockfishPool } from '@se-oss/stockfish';
const pool = new StockfishPool(4); // Create a pool with 4 engine instances
await pool.initialize();
// Acquire an engine, use it, and release it back to the pool
const engine = await pool.acquire();
console.log('Engine acquired');
const analysis = await engine.analyze(
'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
10
);
console.log('Best move from pool engine:', analysis.bestmove);
pool.release(engine);
console.log('Engine released');
// Terminate the pool when done
pool.terminate();
```
## 📚 Documentation
For detailed API documentation on all methods, please see [the API docs](https://www.jsdocs.io/package/@se-oss/stockfish).
## 🤝 Contributing
Want to contribute? Awesome! To show your support is to star the project, or to raise issues on [GitHub](https://github.com/shahradelahi/node-stockfish).
## License
[GPL-3.0](/LICENSE) © [Shahrad Elahi](https://github.com/shahradelahi) and [contributors](https://github.com/shahradelahi/node-stockfish/graphs/contributors).