This module provides a set of functions to help JavaScript Developers working on IBM Quantum Experience projects to authenticate and access API endpoints using Javascript promises.
- Node v12.x
- npm v6.x
- Standard account on IBM Quantum Experience portal
Note: Depending on your Windows setup windows-build-tools may need to be installed first. Also, for MacOS users, you should have xcode-select or entire Xcode App installed.
$ npm install ibm-quantum-js
$ npm uninstall ibm-quantum-js
-
0.1.7
- Fixed security vulnerabilities
-
0.1.6
- Fixed security vulnerability on
ws
- Fixed security vulnerability on
-
0.1.5
- Fixed security vulnerability on
host-git-info
,underscode
, andlodash
- Fixed security vulnerability on
-
0.1.4
- Fixed security vulnerability on
lodash
dependency
- Fixed security vulnerability on
-
0.1.3
- First working module
Perform a login on IBM Q Experience API with API_TOKEN and get a valid auth token:
const quantum = require('ibm-quantum-js');
const token = await quantum.loginWithToken(API_TOKEN);
Note: API_TOKEN is created after you validate your IBM Q Experience user ID. You can find it under "My Account" in the IBM Q Experience web site.
Define a function to return user information from IBM Q:
const quantum = require('ibm-quantum-js');
const userInformation = function(token) {
return quantum.getUserInfo(token).then(function(result){
return result;
}).catch(function(error){
return error;
});
};
Get IBM Q backends (processors):
const backends = await quantum.getIBMBackends(token);
Get IBM Q backend queue status:
const processor = backends[0].name || 'ibmq_qasm_simulator';
const queueStatus = await quantum.getIBMBackendQueue(processor);
Get user experiments from IBM Q:
const userExperiments = await quantum.getUserExperiments(token);
List user jobs in the IBM Q:
const userExperiments = await quantum.listUserJobs(token);
Cancel an user job in the IBM Q:
const userExperiments = await quantum.cancelUserJob(token, jobId);
Execute a new user job in the IBM Q:
const token = await quantum.loginWithToken(API_TOKEN);
const userExperiments = await quantum.postUserJob(token, jobInfo, jobQObject);
Note: jobQObject
is JSON object resulted from a compiled QASM (Quantum Assembly) code. jobInfo
indicates which backend/processor to use.
const JOB_INFO = {
allowObjectStorage: true,
backend: {
name: 'ibmq_qasm_simulator'
}
};
Show the results of a COMPLETED user job in the IBM Q:
const token = await quantum.loginWithToken(API_TOKEN);
const userExperiments = await quantum.showUserJobResults(token, jobId);
loginWithToken(API_TOKEN)
getIBMBackends(token)
getIBMBackendQueue(processor)
getUserInfo(token)
getUserExperiments(token)
cancelUserJob(token, jobId)
listUserJobs(token)
postUserJob(token, jobInfo, jobQObject)
showUserJobResults(token, jobId)
- Unfortunately there's no available API to compile a QASM into a QOBJ, however its JSON schema is published here.
If you want to contribute to the module and make it better, your help is very welcome. You can do so submitting a Pull Request.
Written by Rod Anami [email protected], May 2020. Contributor(s): Paco Martin [email protected]
This project is licensed under the IBM Public License.