I want to get all the spaces in my kibana using python API

I am trying to write a python script to get all the spaces in my Kibana spaces I tried all the different combos but there seems to be no proper way for it.
Here are the few examples that i tired
resp = client.api.spaces()

resp = client.spaces.space()

any help would be appreciated

I can't help on the python side (which library are you using?) but you can definitely use the Kibana HTTP API directly to interact with Spaces


        ## retrive all the spaces names from one master, 
            space_names = requests.get(url_space, auth=(elk_admin_user,elk_admin_password))
            space_names_array = space_names.json()
            for i in range(0,len(space_names_array)):

this will get you all the space names from that server.

I forgot this existed i was able to find the solution here it is

import requests
import json

# Replace with your Kibana URL and credentials
kibana_url = 'https://<kibana_url>/kibana'

headers = {
    'kbn-xsrf': 'true',
    'Content-Type': 'application/json',
    'Authorization': 'Basic <kibana_admin_token>'

# Get a list of all spaces in Kibana
spaces_url = f'{kibana_url}/api/spaces/space'
response = requests.get(spaces_url, headers=headers, verify=True)
spaces = response.json()
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.