Sudoku API
The Sudoku API allows you to generate and solve Sudoku puzzles of various sizes and difficulty levels.
Available endpoints:
- /v1/sudokugenerate - Generate a new Sudoku puzzle
- /v1/sudokusolve - Solve an existing Sudoku puzzle
From 9,384 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 290ms | 336ms | 332ms | 698ms | 981ms |
Didn't find what you were looking for? Suggest an improvement
/v1/sudokugenerate GET
https://api.api-ninjas.com/v1/sudokugenerate
Generate a new Sudoku puzzle with specified parameters.
Parameters
widthoptionalWidth of each box in the Sudoku grid. Default is
3. Must be between2and4.heightoptionalHeight of each box in the Sudoku grid. Default is
3. Must be between2and4.difficultyoptionalDifficulty level of the puzzle. Possible values:
easy,medium,hard. Default ismedium.seedoptionalSeed value for reproducible puzzle generation.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
puzzleA 2D array representing the Sudoku puzzle grid. Empty cells are represented as
null.solutionA 2D array representing the complete solution to the Sudoku puzzle.
Sample Request Live Demo!
Try this API endpoint with all available parameters in our API playground
https://api.api-ninjas.com/v1/sudokugenerate?difficulty=medium&width=3&height=3Headers
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/sudoku?difficulty=easy" \
-H "X-Api-Key: YOUR_API_KEY"If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.
/v1/sudokusolve GET
https://api.api-ninjas.com/v1/sudokusolve
Solve an existing Sudoku puzzle.
Parameters
puzzlerequired2D JSON array representing the Sudoku puzzle. Use
0for empty cells.widthrequiredWidth of each box in the Sudoku grid. Must be between
2and4.heightrequiredHeight of each box in the Sudoku grid. Must be between
2and4.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Content-TyperequiredMust be set to
application/json.
Response
statusThe status of the solution attempt. Possible values:
solvedorunsolvable.solutionA 2D array representing the solved Sudoku puzzle. Only present if
statusissolved.
Sample Request
Try this API endpoint with all available parameters in our API playground
https://api.api-ninjas.com/v1/sudokusolveHeaders
X-Api-KeyLog in or sign up to get your API Key