Sudoku API

The Sudoku API allows you to generate and solve Sudoku puzzles of various sizes and difficulty levels.

Available endpoints:

(4.6)

From 9,384 users

900+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
290ms336ms332ms698ms981ms

Similar APIs

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

  • width  optional

    Width of each box in the Sudoku grid. Default is 3. Must be between 2 and 4.

  • height  optional

    Height of each box in the Sudoku grid. Default is 3. Must be between 2 and 4.

  • difficulty  optional

    Difficulty level of the puzzle. Possible values: easy, medium, hard. Default is medium.

  • seed  optional

    Seed value for reproducible puzzle generation.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

  • puzzle

    A 2D array representing the Sudoku puzzle grid. Empty cells are represented as null.

  • solution

    A 2D array representing the complete solution to the Sudoku puzzle.

Sample Request Live Demo!

difficulty
width
height
seed

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/sudokugenerate?difficulty=medium&width=3&height=3

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON

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

  • puzzle  required

    2D JSON array representing the Sudoku puzzle. Use 0 for empty cells.

  • width  required

    Width of each box in the Sudoku grid. Must be between 2 and 4.

  • height  required

    Height of each box in the Sudoku grid. Must be between 2 and 4.

Headers

  • X-Api-Key  required

    API Key associated with your account.

  • Content-Type  required

    Must be set to application/json.

Response

  • status

    The status of the solution attempt. Possible values: solved or unsolvable.

  • solution

    A 2D array representing the solved Sudoku puzzle. Only present if status is solved.

Sample Request

puzzle
width
height

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/sudokusolve

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON