Extract Excel from Compass
Asked by Nicol? Spito:

For audit reason we need to download all the components of our Atlassian Compass.

Is it possibile to extract in Excel all the Components with last updates date?


Answers:
author: Kelvin T
body: Hello [@Nicol? Spito](/t5/user/viewprofilepage/user-id/5065511)

I hope this message finds you well. My name is Kelvin, and I'm with the Compass Support Team.

At this time, Compass does not offer a native feature to export components to a CSV file. However, you can use the Python script below to generate a CSV file with your Compass components.

Please note that this script was not developed by Atlassian and is therefore not officially supported. We recommend reviewing it carefully before running it.

    import base64import jsonimport requestsimport csv# Define your variables herecloudId = "Your-cloudID"api_token = "Your-API-TOKEN"email = "Email"# Adjust the query to use the cloudId variablequery = f"""query MyQuery {{  compass {{    searchComponents(cloudId: "{cloudId}", query: {{first: 10}}) {{      ... on CompassSearchComponentConnection {{        edges {{          cursor          node {{            component {{              name              typeId              description              labels {{                name              }}              links {{                url              }}              ownerId              applicableScorecards {{                componentTiers {{                  value                }}              }}            }}          }}        }}        totalCount      }}    }}  }}}}"""url = "https://api.atlassian.com/graphql"auth_header = f"{email}:{api_token}"encoded_auth_header = base64.b64encode(auth_header.encode('utf-8')).decode('utf-8')headers = {    "Content-Type": "application/json",    "Accept": "application/json",    "Authorization": f"Basic {encoded_auth_header}",    "X-ExperimentalApi": "compass-beta"}request_data = {    "query": query,}response = requests.post(url, headers=headers, json=request_data)response_data = json.loads(response.text)# Extract the component datacomponents = response_data.get('data', {}).get('compass', {}).get('searchComponents', {}).get('edges', [])# Define the CSV filenamecsv_filename = 'components.csv'# Write the data to a CSV filewith open(csv_filename, mode='w', newline='') as csv_file:    fieldnames = ['name', 'type', 'description', 'labels', 'links', 'owner team', 'applicable scorecards']    writer = csv.DictWriter(csv_file, fieldnames=fieldnames)    writer.writeheader()    for component in components:        node = component.get('node', {})        component_data = node.get('component', {})        writer.writerow({            'name': component_data.get('name', ''),            'type': component_data.get('typeId', ''),            'description': component_data.get('description', ''),            'labels': ', '.join([label.get('name', '') for label in component_data.get('labels', [])]),            'links': ', '.join([link.get('url', '') for link in component_data.get('links', [])]),            'owner team': component_data.get('ownerId', ''),            'applicable scorecards': ', '.join([str(tier.get('value', '')) for scorecard in component_data.get('applicableScorecards', []) for tier in scorecard.get('componentTiers', [])])        })print(f"Data exported to '{csv_filename}'")

comments: author: Guy Derriman
body: Hi Kevin   
Thanks for your snippet here it's very handy   
I have for the life of me not been able to get the value of a CustomField or a Field element   
Can you please update your query to provide a sample of this?  
Component \> CustomFields yields CompassCustomField which have implmentations like CompassCustomTextField that have textValue but I cant work out how to access it. Do I need to cast??  


author: Sebastian Hesse
body: As far as I know, this is not possible (yet?). I guess you want some sort of CSV file that contains all your components with certain fields and then edit/open this file with Excel, right? With a similar (or same) structure like the CSV import from [this documentation page](https://developer.atlassian.com/cloud/compass/components/create-and-update-components-using-a-csv-file/) ?

Edit: Haven't seen the other answer before posting ?

comments: author: Nicol? Spito
body: Mainly for audit reason or to underlight the components that need update from the owners.