A piece of code to communicate from a Python program to XO-Server API.
import json
import aiohttp
import asyncio
from jsonrpc_websocket import Server
async def routine():
async with aiohttp.ClientSession() as client:
server = Server('ws://XO_SERVER_IP/api/', client)
await server.ws_connect()
# No signIn required
methodsInfoResult = await server.system.getMethodsInfo()
print('\n'.join([str(e) for e in methodsInfoResult.keys()]))
# signIn required
result = await server.session.signIn(username='YOUR_LOGIN', password='YOUR_PASSWORD')
result = await server.xo.getAllObjects(filter={"type": "VIF"}, limit=10)
print('[')
print(', \n'.join([str(json.dumps(e, indent=4)) for e in result.values()]))
print(']')
asyncio.get_event_loop().run_until_complete(routine())
This code is using the jsonrpc_websocket_ library.