Docs Github

Get started

The Pocket Cube Solution Finder API provides programmatic access to list of all optimal solutions ( QTM not HTM ) or get a random optimal solution for a given position string of Pocket Cube.

Base URL : https://pocket-cube-solver.vercel.app/

How to get position string of a Pocket Cube state :

  • Hold the pocket cube and view the front face...
  • 'F' denotes the face in front of you
  • 'R' denotes the face to right of 'F'
  • 'L' denotes the face to left of 'F'
  • 'U' denotes the face on top of cube
  • 'D' denotes the bottom face of the cube
  • 'B' denotes the face opposite to 'F'
  • Now record the colors in the same order as the numbers shown above.
  • And now you got a 24-character position string.

Example :

The position string of the cube is:

YWYB ORGR YBOG WWRO YBRO GBGW (without spaces)



The Solution string


The api generates a list of solutions array, where each solution is a string of atmost 14-moves. These are optimal solutions of the given position string ( QTM not HTM ).

List of possible moves:
R, R', U, U', F, F' ( Learn about cube moves )

Apply the moves of any one solution on the F face of the cube to solve it.

get all optimal solutions

To get all solutions you need to make a GET call to the following url :
${baseURL}/:position/all ( Test Query )

QUERY PARAMETERS

Field Type Description Required
position String Position String of a given Pocket Cube Yes

Thats it, there is only one query parameter.

Success Response :

Code : 200
Content : { "position": "String", "depth": "Integer", "sols": "Array(String)" }

Error Response :

Code : 404
Content : { "position": "String", "depth": -1, "sols": [] }

where,
position stores the parameter inputted,
depth contains the number of moves required to solve the given position,
sols contains the list of all optimal solutions which solves the given position.

get a random solution

To get a random optimal solution, you need to make a GET call to the following url :
${baseURL}/:position/random ( Test Query )

QUERY PARAMETERS

Field Type Description Required
position String Position String of a given Pocket Cube Yes

Thats it, there is only one query parameter.

Success Response :

Code : 200
Content : { "position": "String", "depth": "Integer", "sol": "Array(String)" }

Error Response :

Code : 404
Content : { "position": "String", "depth": -1, "sol": null }

where,
position stores the parameter inputted,
depth contains the number of moves required to solve the given position,
sol contains the a random optimal solution which solves the given position.




STATUS CODES

This API uses the following status codes:

Error Code Meaning
404 Some parameters are missing. This error appears when you don't pass every mandatory parameters or pass incorrect parameters.
302 Incorrect request. This error appears if you pass the request incorrectly but instead of throwing error, sends a redirect request to nearest valid accurate request.
200 The requested url is correctly formatted and the response will contain an entity containing the result of the action.