@qbraid-core/ibm-cloud 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ <img align="right" width="100" alt="qbraid" src="https://qbraid-static.s3.amazonaws.com/logos/qbraid.png">
2
+
3
+ # [@qbraid-core/ibm-cloud](https://qbraid.github.io/qbraid-core-js/modules/_qbraid-core_ibm-cloud.html)
4
+
5
+ [![Stable][preview-stability]](https://qbraid.github.io/qbraid-core-js/#launch-stages)
6
+ [![npm](https://img.shields.io/npm/v/@qbraid-core/ibm-cloud?color=blue)](https://npm.im/@qbraid-core/ibm/cloud)
7
+
8
+ IBM Cloud API client used for interacting with IBM's Qiskit Runtime Service API.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @qbraid-core/ibm-cloud
14
+ ```
15
+
16
+ ## Usage Example
17
+
18
+ ```typescript
19
+ import { IBMCloudClient} from '@qbraid-core/ibm-cloud';
20
+
21
+ const apiKey = 'my-api-key';
22
+ const serviceCRN = 'my-service-crn';
23
+
24
+ const client = new IBMCloudClient(apiKey: apiKey, serviceCRN: serviceCRN);
25
+
26
+ // Get a Job
27
+ const jobID = 'my-ibm-job-id';
28
+ const jobResponse = await client.getJob(jobID);
29
+ console.log("Job details: ", jobResponse);
30
+
31
+ // Get all devices
32
+ const backends = await client.getBackends();
33
+ console.log("Available backends: ", backends);
34
+
35
+ // Get a backend status
36
+ const backendName = 'ibm_marrakesh';
37
+ const backendStatus = await client.getBackendStatus(backendName);
38
+ console.log("Backend status: ", backendStatus);
39
+ ```
40
+
41
+ ## License
42
+
43
+ This software is proprietary and subject to the terms of the [qBraid Commercial Software License](https://qbraid.github.io/qbraid-core-js/#license).
44
+
45
+ [stable-stability]: https://img.shields.io/badge/stability-stable-green
46
+ [preview-stability]: https://img.shields.io/badge/stability-preview-orange
47
+ [deprecated-stability]: https://img.shields.io/badge/stability-deprecated-red
@@ -0,0 +1,21 @@
1
+ import { AllDevicesResponse, DeviceProperties, DeviceConfiguration, DeviceStatus, JobList, Job, GetJobParams, CancelJobResponse, DeleteJobResponse } from './types';
2
+ export declare class IBMCloudClient {
3
+ private apiKey?;
4
+ private token?;
5
+ private crn;
6
+ private baseUrl;
7
+ private client;
8
+ constructor({ apiKey, token, crn }: {
9
+ apiKey?: string;
10
+ token?: string;
11
+ crn: string;
12
+ });
13
+ getBackends(): Promise<AllDevicesResponse>;
14
+ getBackendProperties(backendName: string, updatedBefore?: string): Promise<DeviceProperties>;
15
+ getBackendConfiguration(backendName: string): Promise<DeviceConfiguration>;
16
+ getBackendStatus(backendName: string): Promise<DeviceStatus>;
17
+ getJobs(params?: GetJobParams): Promise<JobList>;
18
+ getJob(jobId: string, excludeParams?: boolean): Promise<Job>;
19
+ deleteJob(jobId: string): Promise<DeleteJobResponse>;
20
+ cancelJob(jobId: string, parentJobId?: string): Promise<CancelJobResponse>;
21
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ // Copyright (c) 2025, qBraid Development Team
3
+ // All rights reserved.
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.IBMCloudClient = void 0;
9
+ const https_1 = require("https");
10
+ const axios_1 = __importDefault(require("axios"));
11
+ class IBMCloudClient {
12
+ apiKey;
13
+ token;
14
+ crn;
15
+ baseUrl;
16
+ client;
17
+ constructor({ apiKey, token, crn }) {
18
+ if (!apiKey && !token) {
19
+ throw new Error('Either apiKey or token must be provided');
20
+ }
21
+ this.apiKey = apiKey;
22
+ this.token = token;
23
+ this.crn = crn;
24
+ this.baseUrl = 'https://us-east.quantum-computing.cloud.ibm.com/';
25
+ const headers = {
26
+ 'Service-CRN': this.crn,
27
+ Authorization: this.apiKey ? `apikey ${this.apiKey}` : `Bearer ${this.token}`,
28
+ };
29
+ const axiosInstance = axios_1.default.create({
30
+ baseURL: this.baseUrl,
31
+ headers,
32
+ httpsAgent: new https_1.Agent({ keepAlive: true }),
33
+ });
34
+ this.client = axiosInstance;
35
+ }
36
+ // 1. GET /backends - get all backends from IBM
37
+ async getBackends() {
38
+ const response = await this.client.get('/backends');
39
+ return response.data;
40
+ }
41
+ // 2. GET /backends/:backend_name/properties - get all properties of a specific backend
42
+ async getBackendProperties(backendName, updatedBefore // format : YYYY-MM-DDThh:mm:ssZ
43
+ ) {
44
+ const params = updatedBefore ? { updated_before: updatedBefore } : undefined;
45
+ const response = await this.client.get(`/backends/${backendName}/properties`, { params: params });
46
+ return response.data;
47
+ }
48
+ // 3. GET /backends/:backend_name/configuration - get all configuration of a specific backend
49
+ async getBackendConfiguration(backendName) {
50
+ const response = await this.client.get(`/backends/${backendName}/configuration`);
51
+ return response.data;
52
+ }
53
+ // 4. GET /backends/:backend_name/status - get the status of a specific backend
54
+ async getBackendStatus(backendName) {
55
+ const response = await this.client.get(`/backends/${backendName}/status`);
56
+ return response.data;
57
+ }
58
+ // 5. GET /jobs - get all jobs from IBM
59
+ async getJobs(params) {
60
+ const response = await this.client.get('/jobs', { params });
61
+ return response.data;
62
+ }
63
+ // 6. GET /jobs/:job_id - get a specific job from IBM
64
+ async getJob(jobId, excludeParams) {
65
+ const response = await this.client.get(`/jobs/${jobId}`, {
66
+ params: { exclude_params: excludeParams }, // true will omit the params field in response
67
+ });
68
+ return response.data;
69
+ }
70
+ // 7. DELETE /jobs/:job_id - delete a specific job from IBM
71
+ async deleteJob(jobId) {
72
+ const response = await this.client.delete(`/jobs/${jobId}`);
73
+ return response.data;
74
+ }
75
+ // 8. POST /jobs/:job_id/cancel - cancel a specific job from IBM
76
+ async cancelJob(jobId, parentJobId) {
77
+ const customHeader = parentJobId ? { 'parent-job-id': parentJobId } : {};
78
+ const response = await this.client.post(`/jobs/${jobId}/cancel`, null, {
79
+ headers: {
80
+ ...this.client.defaults.headers.common,
81
+ ...customHeader,
82
+ },
83
+ });
84
+ return response.data;
85
+ }
86
+ }
87
+ exports.IBMCloudClient = IBMCloudClient;
88
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,uBAAuB;;;;;;AAEvB,iCAA8B;AAE9B,kDAA0B;AAe1B,MAAa,cAAc;IACjB,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,GAAG,CAAS;IACZ,OAAO,CAAS;IAChB,MAAM,CAAgB;IAE9B,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAoD;QAClF,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,kDAAkD,CAAC;QAClE,MAAM,OAAO,GAAG;YACd,aAAa,EAAE,IAAI,CAAC,GAAG;YACvB,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,KAAK,EAAE;SAC9E,CAAC;QACF,MAAM,aAAa,GAAG,eAAK,CAAC,MAAM,CAAC;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO;YACP,UAAU,EAAE,IAAI,aAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;SAC3C,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;IAC9B,CAAC;IAED,+CAA+C;IAC/C,KAAK,CAAC,WAAW;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAqB,WAAW,CAA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EAAE,aAAa,EAAE,EAAE,8CAA8C;SAC1F,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,2DAA2D;IAC3D,KAAK,CAAC,SAAS,CAAC,KAAa;QAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAoB,SAAS,KAAK,EAAE,CAAC,CAAC;QAC/E,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,gEAAgE;IAChE,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,WAAoB;QACjD,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEzE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAoB,SAAS,KAAK,SAAS,EAAE,IAAI,EAAE;YACxF,OAAO,EAAE;gBACP,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM;gBACtC,GAAG,YAAY;aAChB;SACF,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AA7FD,wCA6FC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @module ibm-cloud
3
+ */
4
+ export { IBMCloudClient } from './client';
5
+ export type { DeleteJobResponse, CancelJobResponse, RunJobResponse, Job, JobList, DeviceProperties, DeviceStatus, DeviceConfiguration, } from './types';
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // Copyright (c) 2025, qBraid Development Team
3
+ // All rights reserved.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.IBMCloudClient = void 0;
6
+ /**
7
+ * @module ibm-cloud
8
+ */
9
+ var client_1 = require("./client");
10
+ Object.defineProperty(exports, "IBMCloudClient", { enumerable: true, get: function () { return client_1.IBMCloudClient; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,uBAAuB;;;AAEvB;;GAEG;AACH,mCAA0C;AAAjC,wGAAA,cAAc,OAAA"}
@@ -0,0 +1,217 @@
1
+ export interface AllDevicesResponse {
2
+ devices: string[];
3
+ }
4
+ export interface GateParam {
5
+ date: string;
6
+ name: string;
7
+ unit: string;
8
+ value: number;
9
+ }
10
+ export interface Gate {
11
+ gate: string;
12
+ name: string;
13
+ parameters: GateParam[];
14
+ qubits: number[];
15
+ }
16
+ export interface Property {
17
+ date: string;
18
+ name: string;
19
+ unit: string;
20
+ value: number;
21
+ }
22
+ export type Qubit = Property[];
23
+ export interface QList {
24
+ name: string;
25
+ qubits: number[];
26
+ }
27
+ export interface DeviceProperties {
28
+ backend_name: string;
29
+ backend_version: string;
30
+ gates: Gate[];
31
+ general: Property[];
32
+ general_qlists: QList[];
33
+ last_update_date: string;
34
+ qubits: Qubit[];
35
+ }
36
+ export type QubitMap = {
37
+ [key: string]: number;
38
+ };
39
+ export type VarMap = {
40
+ [key: string]: number;
41
+ };
42
+ export interface Channel {
43
+ operates: {
44
+ qubits: number[];
45
+ };
46
+ purpose: string;
47
+ type: string;
48
+ }
49
+ export type ChannelsMap = {
50
+ [key: string]: Channel;
51
+ };
52
+ export interface Hamiltonian {
53
+ description: string;
54
+ h_latex: string;
55
+ h_str: string[];
56
+ osc: any;
57
+ qub: QubitMap;
58
+ vars: VarMap;
59
+ }
60
+ export interface ProcessorType {
61
+ family: string;
62
+ revision: number;
63
+ }
64
+ export interface PhysicalGate {
65
+ name: string;
66
+ parameters: string[];
67
+ qasm_def: string;
68
+ coupling_map: number[][];
69
+ }
70
+ export interface UChannelLo {
71
+ q: number;
72
+ scale: number[];
73
+ }
74
+ export interface DeviceConfiguration {
75
+ allow_q_object: boolean;
76
+ backend_name: string;
77
+ backend_version: string;
78
+ clops: null;
79
+ clops_h: number;
80
+ clops_v: string;
81
+ conditional: boolean;
82
+ credits_required: boolean;
83
+ default_rep_delay: number;
84
+ description: string;
85
+ dt: number;
86
+ dtm: number;
87
+ dynamic_reprate_enabled: boolean;
88
+ local: boolean;
89
+ max_experiments: number;
90
+ max_shots: number;
91
+ measure_esp_enabled: boolean;
92
+ memory: boolean;
93
+ multi_meas_enabled: boolean;
94
+ n_qubits: number;
95
+ n_registers: number;
96
+ n_uchannels: number;
97
+ online_date: string;
98
+ open_pulse: boolean;
99
+ parallel_compilation: boolean;
100
+ quantum_volume: number;
101
+ sample_name: string;
102
+ simulator: boolean;
103
+ timing_constraints: {
104
+ acquire_alignment: number;
105
+ granularity: number;
106
+ min_length: number;
107
+ pulse_alignment: number;
108
+ };
109
+ uchannels_enabled: boolean;
110
+ url: string;
111
+ basis_gates: string[];
112
+ channels: ChannelsMap;
113
+ acquisition_latency: number[][];
114
+ conditional_latency: number[][];
115
+ coords: number[][];
116
+ coupling_map: number[][];
117
+ discriminators: string[];
118
+ gates: PhysicalGate[];
119
+ hamiltonian: Hamiltonian;
120
+ meas_levels: number[];
121
+ meas_kernels: string[];
122
+ meas_lo_range: number[][];
123
+ meas_map: number[][];
124
+ parametric_pulses: string[];
125
+ processor_type: ProcessorType;
126
+ qubit_channel_mapping: string[][];
127
+ qubit_lo_range: number[][];
128
+ rep_delay_range: number[];
129
+ rep_times: number[];
130
+ supported_features: string[];
131
+ supported_instructions: string[];
132
+ u_channel_lo: UChannelLo[][];
133
+ }
134
+ export interface DeviceStatus {
135
+ state: boolean;
136
+ status: string;
137
+ message: string;
138
+ length_queue: number;
139
+ backend_version: string;
140
+ }
141
+ export interface JobState {
142
+ status: string;
143
+ reason?: string;
144
+ reason_code?: number;
145
+ reason_solution?: string;
146
+ }
147
+ export interface RemoteStorage {
148
+ type: string;
149
+ region: string;
150
+ region_type: string;
151
+ bucket_crn: string;
152
+ job_params: {
153
+ type: string;
154
+ region: string;
155
+ region_type: string;
156
+ bucket_crn: string;
157
+ object_name: string;
158
+ };
159
+ }
160
+ export interface Job {
161
+ id: string;
162
+ state: JobState;
163
+ status: string;
164
+ program: {
165
+ id: string;
166
+ };
167
+ created: string;
168
+ cost: number;
169
+ backend?: string;
170
+ params?: any;
171
+ runtime?: string;
172
+ tags?: string[];
173
+ remote_storage?: RemoteStorage;
174
+ session_id?: string;
175
+ user_id?: string;
176
+ usage?: {
177
+ seconds: number;
178
+ };
179
+ }
180
+ export interface JobList {
181
+ limit: number;
182
+ offset: number;
183
+ jobs?: Job[];
184
+ count?: number;
185
+ }
186
+ export interface GetJobParams {
187
+ limit?: number;
188
+ offset?: number;
189
+ pending?: boolean;
190
+ program?: string;
191
+ backend?: string;
192
+ created_after?: string;
193
+ created_before?: string;
194
+ sort?: string;
195
+ tags?: string[];
196
+ session_id?: string;
197
+ exclude_params?: boolean;
198
+ }
199
+ export interface RunJobResponse {
200
+ id: string;
201
+ backend: string;
202
+ session_id?: string;
203
+ }
204
+ export interface ErrorResponse {
205
+ code: number;
206
+ message: string;
207
+ solution: string;
208
+ more_info: string;
209
+ }
210
+ export interface CancelJobResponse {
211
+ errors?: ErrorResponse[];
212
+ trace?: string;
213
+ }
214
+ export interface DeleteJobResponse {
215
+ errors?: ErrorResponse[];
216
+ trace?: string;
217
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // Copyright (c) 2025, qBraid Development Team
3
+ // All rights reserved.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,uBAAuB"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@qbraid-core/ibm-cloud",
3
+ "version": "0.7.0",
4
+ "main": "dist/src/index.js",
5
+ "types": "dist/src/index.d.ts",
6
+ "description": "Functionality for interacting with Qiskit Runtime services on qBraid Cloud.",
7
+ "author": "qBraid Development Team",
8
+ "license": "Proprietary",
9
+ "files": [
10
+ "dist/src"
11
+ ],
12
+ "keywords": [
13
+ "qbraid",
14
+ "qbraid-core",
15
+ "qbraid-core-js",
16
+ "qbraid ibm",
17
+ "qbraid cloud",
18
+ "qbraid api",
19
+ "qbraid apis",
20
+ "cloud",
21
+ "quantum",
22
+ "quantum computing",
23
+ "ibm"
24
+ ],
25
+ "repository": {
26
+ "type": "git",
27
+ "directory": "packages/ibm-cloud",
28
+ "url": "git+https://github.com/qBraid/qbraid-core-js.git"
29
+ },
30
+ "homepage": "https://qbraid.github.io/qbraid-core-js/modules/ibm-cloud.html",
31
+ "dependencies": {
32
+ "axios": "^1.7.9",
33
+ "fs": "^0.0.1-security",
34
+ "ini": "^5.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/ini": "^4.1.1"
38
+ },
39
+ "scripts": {
40
+ "clean": "rimraf dist tsconfig.tsbuildinfo src/*.js",
41
+ "lint": "eslint src",
42
+ "lint:fix": "eslint src --fix",
43
+ "format": "prettier --write \"src/**/*.{ts,json}\"",
44
+ "format:check": "prettier --check \"src/**/*.{ts,json}\"",
45
+ "docs": "typedoc"
46
+ },
47
+ "engines": {
48
+ "node": ">=20"
49
+ }
50
+ }