The Solver API (SAPI) is a front-end for the D-Wave quantum processing unit (QPU) solver and a variety of other advanced software solvers. A REST-based web services API, SAPI is used internally by D-Wave client applications.
|||A solver is simply a resource that receives a problem and returns an answer; it may be a D-Wave QPU or a software emulation of one.|
SAPI allows you to formulate a wide range of problems amenable to quantum acceleration. The API is fairly simple to use; it exposes only a few basic calls. Most of the work for you will be restructuring your problem into a format that the API can answer, and then parsing results.
What is REST?¶
REST, which stands for Representational State Transfer, is a lightweight web services protocol. It came into being as a response to heavyweight Web services protocols such as SOAP and XML-RPC, which rely on a predefined messaging format and methods to pass them back and forth between servers and clients. REST, on the other hand, specifies no such limitations; you can use any message format that you like (whether it be JSON, XML, HTML, serialized data, or even straight text), and operates on the standard HTTP verbs of GET, DELETE, and POST for its operations.
Each REST web services call is a simple HTTP request, using one of the standard HTTP verbs:
- GET—Retrieve data from a server
- POST—Send data to a server
- DELETE—Delete a resource from a server
HTTP Response Codes¶
|200 OK||No error.|
|201 CREATED||Creation of a resource was successful.|
|202 ACCEPTED||Problem cancellation request was received.|
|304 NOT MODIFIED||The resource hasn’t changed since the time specified in the request’s
|400 BAD REQUEST||Invalid request URI or header, or unsupported nonstandard parameter.|
|401 UNAUTHORIZED||Authorization required. This error can also mean that incorrect user credentials were sent with the request.|
|403 FORBIDDEN||Unsupported standard parameter, or authentication or authorization failed.|
|404 NOT FOUND||Resource (such as a problem) not found.|
|409 ALREADY TERMINATED||Problem reached one of terminal states before the call.|
|429 TOO MANY REQUESTS||API request rate exceeds the permissible limit.|
|500 INTERNAL SERVER ERROR||Internal error. This is the default code that is used for all unrecognized server errors.|
Examples in this document use
curl to send HTTP requests to the SAPI web service. Set the base URL and
the API token environment variables to the home URL of the SAPI web service and an API key on the server hosting
the web service respectively. Solver API endpoints are specific to a region.
The following example sets the base URL and the API token environment variables:
export SAPI_HOME=https://na-west-1.cloud.dwavesys.com/sapi/v2 export SAPI_TOKEN=ProjectA-tokens-string
- All URLs referenced in the documentation have the following base: https://na-west-1.cloud.dwavesys.com/sapi/v2.
This API endpoint can vary based on the system setup and is referenced throughout the document as
- The former base https://cloud.dwavesys.com/sapi/ defaults to https://na-west-1.cloud.dwavesys.com/sapi/v2. The https://cloud.dwavesys.com/sapi/ endpoint will be deprecated in a future release.
- The default region is North America.
- The regional solver API endpoints that are available to you are displayed in the Leap Dashboard.
Authentication and Access¶
All requests to SAPI require users to authenticate using an API token. API tokens are associated with projects. Each project has a priority and one or more solvers that users who are assigned to that project can access. Each problem that SAPI accepts is authenticated via the token and sent to a solver for solution. API tokens do not differentiate between solvers in their project.
An API token is sent to SAPI in the form of HTTP header
A simple example of getting list of remote solvers using
curl is as follows:
SAPI_HOME=https://na-west-1.cloud.dwavesys.com/sapi/v2 SAPI_TOKEN=ProjectA-tokens-string curl -H "X-Auth-Token: $SAPI_TOKEN" $SAPI_HOME/solvers/remote/
Projects and individual users may have quotas configured, which control solver access time.