AYON Python API First Steps

ayon-python-api

ayon-python-api is our official library to interact with AYON server from python code.
Find it here GitHub - ynput/ayon-python-api.

Get Started

It’s as easy as

pip install ayon-python-api

First Steps

It requires AYON_SERVER_URL and AYON_API_KEY environment variables to connect with AYON server.

import os
os.environ["AYON_SERVER_URL"] = "<your-ayon-server-url>"
os.environ["AYON_API_KEY"] = "<your-ayon-api-key>"

import ayon_api
con = ayon_api.get_server_api_connection()
projects = con.get_projects()
print(projects)

AYON Python API usage

It’s used to interact with AYON server where you can

  • Retrieve some information
  • Perform some actions

Here are some examples.

These examples assumes that you have already configured AYON_SERVER_URL, AYON_API_KEY environment variables.

Get Project Names

import ayon_api
con = ayon_api.get_server_api_connection()

projects = con.get_projects()
projects_names = [] 
for p in  projects:
  projects_names .append(p["name"])

print("Current Projects:", projects_names)

Get User info

import ayon_api
con = ayon_api.get_server_api_connection()

users = con.get_users()
users_names = [] 
for user in  users :
  users_names.append(user["name"])

print("Current Users:", users_names)

Upload Addon

import ayon_api

con = ayon_api.get_server_api_connection()
addon_zip_path = "<addon-zip-file-path>"
result = con.upload_addon_zip(addon_zip_path)
print(result) 
# result contains 'eventId'. 
# you can go to event viewer on Ayon server and check it status.

More Info

Since the documentation is still in progress.
You’d need to search the repo to find what you need GitHub - ynput/ayon-python-api
Specifically, methods of ServerAPI class

Also, you might need to look at Ayon server | AYON Docs

Also, It’s worth mentioning that we have an advanced AYON REST API Guide