Python SDK

Introduction #

In order to ease the use of the QCentroid Platform API, we have devolped an SDK in Python.

This SDK is a very simple class that provides a wrapper for easy access to the most used endpoint.

Description #

Imports #

Only two external librares are used by the SDK:

import requests
import json

Methods #

The following methods are defined in the SDK:

def login()
def execute(header, problem, payload)
def get_result(header, job_name)
def get_results(header)
def get_best_result(header, job_name)

Usage examples #

This is an example of how to obtain a random number using the Quantun Random Numbers Generator (QRNG):

# Import the QCentroid SDK package and other auxiliary packages. Make sure that all packages are installed
from Qcentrod import Qcentroid_SDK
import time
from IPython.display import display, clear_output

# Set your private endpoint and credentials
PAYLOAD_USER = {"username": "your-username", "password": "your-password"}

# This problem only recieves one parameter. The size of the bitstring of randomness to receive
    "data": {
        "size": 50

# Initialize the SDK

# API login using the credentials set above
# Save the header (with your temporal access token) to be used in following requests
header = qcentroid_api.login()

# Execute the Job
response_json = qcentroid_api.execute(header=header, problem='qrng', payload=PAYLOAD_QRNG)

# Extract the Job Id from the response
job_id = response_json['job']

# Obtain the result using the Job Id
result = qcentroid_api.get_result(header=header, job_name=job_id)

# Print the result
print("Execution Result:")

GitHub Resources #

Check the SDK in Github:

Check the tutorials that use the SDK: