Back to Yugabyte Db

List Universes

managed/api-examples/python-client/list-universes.ipynb

2026.1.0.0-b251.4 KB
Original Source

Setup

First, import the required packages.

Next, specify some important variables:

  • platform_address: The address of the Yugabyte Platform API
  • platform_api_key: The API key used to authenticate with the Platform API

Finally, create the Yugabyte Platform API client object.

python
import os
import yb_platform_client
from yb_platform_client.api import universe_api, session_api

platform_address = 'http://localhost:9000'
platform_api_key = os.getenv('YB_API_KEY')

api_client = yb_platform_client.ApiClient(yb_platform_client.Configuration(
    host = platform_address,
    api_key = {
        'apiKeyAuth': platform_api_key,
    }
))

Get Session Info

Make an API call to session endpoint to determine customer UUID.

python
session_api = session_api.SessionApi(api_client)

try:
    session_info = session_api.get_session_info()
except yb_platform_client.ApiException as e:
    print("Error get_session_info: %s" % e)
    raise

customer_uuid = session_info.get('customer_uuid')
print('Customer UUID:\n%s' % customer_uuid)

List Universes

Make API call to provider endpoint to list universes.

python
universe_api = universe_api.UniverseApi(api_client)

try:
    universe_list = universe_api.get_list_of_universes(customer_uuid)
except yb_platform_client.ApiException as e:
    print('Error get_list_of_universes: %s' % e)
    raise

print('Universes:\n%s' % universe_list)