XINA API Libraries
We aim to provide a variety of reference XINA API client implementations for different programming languages and environments.
Python
xina_api_python_1.0.xina_api_python_0.4.0.zip
Installation
Prerequisites
- Python 3.8 or greater
The xina
client communicates with XINA via the XINA Tunnel utility. You must have it running for the xina
client to connect.
Steps
- Extract the zip file.
- Open a terminal in the root extracted directory, and execute the following
commands:
python3 install .
Examples
Client class
import socket
from xina import XPClient
with socket.socket(XPClient() as sock:
sock.settimeout(5.) # Five seconds is the recommended socket timeout.
sock.connect(('localhost', 41746))
with XPClient(sock=sock) as x:
x.init()
res = x.act({'action': 'version'})
print(res)
# => {'schema':100, 'host':'sandbox.xina.io', 'server':'9.1.4', 'team':100}
CLI
python -m xina action '{"action":"version"}'
# => {"schema":100,"host":"sandbox.xina.io","server":"9.1.4","team":100}