IL2Client

The main class to connect to an IL2 node. The IL2Client will store the IL2 node host address and the PFX certificate to access the node. To instantiate an IL2Client:

from pyil2 import IL2Client

client = IL2Client(
    host='https://il2.node:32032/',
    cert_filepath='rest.api.pfx',
    cert_password='Str0ngPassword'
)
print(client.api_list)

The details about the IL2Client are as follows:

class pyil2.IL2Client(host: str, cert_filepath: str, cert_password: str, verify_ca: bool = True, timeout: int = 30)

Bases: object

REST API client to the InterlockLedger node.

You’ll try to establish a bi-authenticated https connection with the configured node API address and port. The client-side certificate used to connect needs to be configured with the proper layered authorization role in the node configuration file and imported into a key permitted to update the chain that will be used.

Parameters:
  • host (str) – Host address in the format: scheme://hostmane[:port][/].

  • cert_filepath (str) – Path to the .pfx certificate. Please refer to the InterlockLedger manual to see how to create and import the certificate into the node.

  • cert_password (str) – Password of the .pfx certificate.

  • verify_ca (bool) – If True, verifies the SSL certificate in a CA (default: True).

  • connect_timeout (int) – Connect timeout in seconds (default: 5s).

  • read_timeout (int) – Read timeout in seconds (default 30s).

api(name: str) NodeApi | ChainApi | RecordApi | OpaqueApi | JsonApi | DocumentsApi

Get an instance of an API.

Parameters:

name (str) – API name.

Returns:

Instance of an API.

Return type:

BaseApi

property api_list: List[str]

List of available APIs.

Type:

[str]

download_file(url: str, dst_path: str = './', params: Dict[str, str] = None) str

Method to download a file to a destination path.

We do not recommend using this method directly.

download_response(url: str, params: Dict[str, str] = None) Response

Method to retrieve an stream GET response directly.

We do not recommend using this method directly.

property public_certificate_in_x509

Public certificate in X509 format.

Type:

str

request(url: str, method: str, accept: str = 'application/json', content_type: str = 'application/json', body: Dict[str, Any] = None, params: Dict[str, str] = None, data: bytes = None, headers: Dict[str, str] = None) Response

This method is used to wrap IL2 requests. We do not recommend using this method directly.