Skip to main content
IBM Quantum Platform

Set up to use IBM Quantum Platform with REST API

You can access quantum processors with REST APIs, enabling you to work with QPUs using any programming language or framework.

1. Get access

  1. If you do not already have a user account, get one at the IBM Quantum login page.
  2. Create an API key (also called a token) on the dashboard. Note that the same API key can be used for either region.
  3. Generate an IBM Cloud Identity and Access Management (IAM) bearer token. This is a short-lived token used to authenticate requests to the REST API. To generate one, call the IAM Identity Services API as shown in the following sample request:
curl -X POST 'https://iam.cloud.ibm.com/identity/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=MY_APIKEY'

Expected Response

{
   "access_token": "eyJhbGciOiJIUz......sgrKIi8hdFs",
   "refresh_token": "SPrXw5tBE3......KBQ+luWQVY=",
   "token_type": "Bearer",
   "expires_in": 3600,
   "expiration": 1473188353
}

2. Choose an authentication method

Choose the appropriate authentication method, depending on your working environment:

Create an environment variable (trusted environment)

  1. To set the IQP_API_TOKEN environment variable in your system, you can add the following line to your shell profile (for example, .bashrc or .zshrc) or by setting it directly in your terminal:

    export IQP_API_TOKEN=<your-token>

    When you invoke the environment variable in your code, include import os, as in this example:

    import os
    api_token = os.environ['IQP_API_TOKEN']

    Note that when creating an environment variable, your API key is still stored locally in plain text, and should be safeguarded.

  2. Authenticate requests to the Qiskit Runtime REST API by including the CRN and bearer token to the request's headers.

curl -X 'GET' \
   'https://quantum.cloud.ibm.com/api/v1/usage' \
   '-H accept: application/json' \
   '-H authorization: Bearer <BEARER_TOKEN>' \
   '-H Service-CRN: crn:v1:bluemix:public:quantum-computing:us-east:a/b947c1c5a9378d64aed96696e4d76e8e:a3a7f181-35aa-42c8-94d6-7c8ed6e1a94b::'

3. Optional: Configure your firewall

If necessary, use this information to enable access to the IBM Quantum API endpoints.


Next steps

Recommendations
Was this page helpful?
Report a bug or request content on GitHub.