A powerful chess analysis API that supports multiple engines and can be deployed on any web hosting platform, including Namecheap shared hosting.
- Multiple Chess Engines: Stockfish.js, JS-Chess-Engine, and more
- Browser Compatible: Works directly in web browsers
- REST API: Clean endpoints for integration
- Tampermonkey Ready: Drop-in replacement for existing extensions
- Easy Deployment: Works on shared hosting (no VPS required)
index.html
- Main dashboard and testing interfacechess-api.js
- JavaScript chess engine implementationapi-server.php
- PHP server for shared hosting compatibilityREADME.md
- This documentation
- โ Stockfish.js - Professional strength (~3200 ELO)
- โ JS-Chess-Engine - Lightweight engine (~2000 ELO)
- โ Ensemble Analysis - Consensus from multiple engines
- โ Position Evaluation - Comprehensive position analysis
- โ Browser-based - No server installations required
-
Upload files to your hosting:
public_html/ โโโ index.html โโโ chess-api.js โโโ api-server.php โโโ README.md
-
Configure URL rewriting (create
.htaccess
):RewriteEngine On RewriteRule ^api/(.*)$ api-server.php [QSA,L]
-
Test your API: Visit
https://yourdomain.com
Simply upload all files to your web root directory. The API will work immediately!
POST /api/best-move
Content-Type: application/json
{
"fen": "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1",
"depth": 15,
"engine": "stockfish",
"elo_limit": 2800
}
Response:
{
"best_move": "e7e5",
"evaluation": {
"cp": 25,
"mate": null
},
"engine_used": "stockfish",
"depth_reached": 15,
"analysis_time": 0.85
}
POST /api/evaluation
Content-Type: application/json
{
"fen": "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1",
"perspective": "white"
}
POST /api/ensemble
Content-Type: application/json
{
"fen": "r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 0 4",
"engines": ["stockfish", "jsengine"],
"depth": 12
}
GET /api/engines/status
Replace your existing API calls with your new API:
const data = await fetch(`https://herolalispro.pythonanywhere.com/chessapi/enginePost/?fen=${fen}&depth=${power}&elo=${elo}`)
const data = await fetch(`https://yourdomain.com/api/best-move`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
fen: fen,
depth: power,
elo_limit: elo,
engine: 'stockfish'
})
})
- Strength: ~3200 ELO
- Type: Professional engine (JavaScript port)
- Best for: Serious analysis, tournament play
- Strength: ~2000 ELO
- Type: Lightweight JavaScript engine
- Best for: Quick analysis, educational use
- Combines: Multiple engines for consensus
- Confidence: Weighted voting system
- Best for: Critical positions, double-checking
- Open
https://yourdomain.com
in your browser - Click test buttons to verify engines work
- Check the response format matches your extensions
- Update your Tampermonkey scripts with the new URL
Edit chess-api.js
and add your engine:
async getCustomEngineMove(fen, depth) {
// Your engine implementation
return {
best_move: 'e2e4',
evaluation: { cp: 25, mate: null },
engine_used: 'custom',
depth_reached: depth
};
}
In ensemble analysis, modify weights in api-server.php
:
$weights = [
'stockfish' => 0.7, // 70% weight
'jsengine' => 0.3 // 30% weight
];
- Stockfish.js: 0.5-2.0 seconds (depth 15)
- JS-Engine: 0.1-0.5 seconds (depth 10)
- Ensemble: 1.0-3.0 seconds (multiple engines)
- Shared Hosting: 10-50 concurrent requests
- VPS: 100+ concurrent requests
- CORS enabled for browser extensions
- Input validation for FEN strings
- Rate limiting (can be added)
- Error handling with fallback moves
1. API not responding
- Check file permissions (755 for directories, 644 for files)
- Verify PHP is enabled on your hosting
- Check error logs in cPanel
2. CORS errors
- Ensure
Access-Control-Allow-Origin: *
headers are set - Check browser console for specific errors
3. Engine not loading
- Verify internet connection (engines load from CDN)
- Check browser console for JavaScript errors
- Try refreshing the page
4. Slow responses
- Reduce analysis depth in requests
- Use lighter engines (JS-Engine instead of Stockfish)
- Check hosting provider performance
Add ?debug=1
to your URL to see detailed logs:
https://yourdomain.com/?debug=1
To update the API:
- Backup your current files
- Upload new versions
- Clear browser cache
- Test functionality
Your extensions can now choose engines dynamically:
// Use Stockfish for serious games
const strongMove = await getMove(fen, 'stockfish', 15);
// Use JS-Engine for quick hints
const quickMove = await getMove(fen, 'jsengine', 8);
// Use ensemble for critical positions
const consensusMove = await getMove(fen, 'ensemble', 12);
function selectBestEngine(fen) {
const moveNumber = parseInt(fen.split(' ')[5]);
if (moveNumber <= 10) return 'jsengine'; // Opening
if (moveNumber <= 40) return 'stockfish'; // Middlegame
return 'ensemble'; // Endgame
}
- Add Leela Zero integration
- Implement caching for analyzed positions
- Add opening book database
- Create mobile-friendly interface
- Add game analysis features
- Implement user accounts and preferences
If you need help:
- Check the troubleshooting section
- Review browser console for errors
- Test with the built-in testing interface
- Verify all files uploaded correctly
This project is open source. Feel free to modify and distribute.
๐ฏ Ready to dominate chess.com with your own multi-engine API!
Replace those old APIs and enjoy the power of multiple chess engines working together.