Getting Started

Start integrating GoodData into your Python application right now.

Quick Start

  1. Install Python SDK

  2. Ensure you have a running instance of GoodData. If you just want to try things out, we recommend you sign up for a trial of GoodData Cloud.

  3. Create a personal access token for GoodData API

  4. Import Python SDK into your script:

    from gooddata_sdk import GoodDataSdk
    
  5. Connect to your instance of GoodData using:

    # GoodData base URL, e.g. "https://www.example.com"
    host = "https://www.example.com"
    token = "<your_personal_access_token>"
    sdk = GoodDataSdk.create(host, token)
    

    Alternatively, you can create the instance from a config file:

    # The default path to the profiles.yaml file is set to `~/.gooddata/profiles.yaml`
    # It can be overridden with a custom path
    profiles= Path("~/my_directory/my_profiles.yaml")
    # Profile name defaults to `default. It can be overridden with a custom profile
    sdk = GoodDataSdk.create_from_profile(profile="staging", profiles_path=profiles)
    

    profiles.yaml file structure example:

    default:
        host: http://localhost:3000
        token: YWRtaW46Ym9vdHN0cmFwOmFkbWluMTIz
        custom_headers: #optional
            Host: localhost
        extra_user_agent: xyz #optional
    
  6. Start using Python SDK! For example, get a list of all workspaces:

    workspaces = sdk.catalog_workspace.list_workspaces()
    print(workspaces)
    
    
    # [
    #   CatalogWorkspace(id=demo_west, name=Demo West),
    #   CatalogWorkspace(id=demo_west_california, name=Demo West California),
    #   CatalogWorkspace(id=demo, name=Demo)
    # ]
    

About This Documentation

This documentation serves mostly as a referential documentation, altough, you will find example codes scattered throughout it.

Reading the example code

The are two types of example codes in this documentation.

First is the standalone and the second is the snippet type. The main difference between those two types is that when working with the standalone, it contains all the necessary includes and variables used. Meaning, that after changing the host and token representing your URI and API token respectively, the code is executable. Where the snippet type code does not contain any import statements or variable declarations, unless tightly tied to the method used.

Standalone type

The standalone code examples are contained in in the “navigation” parts of the documentation and are usually use-case oriented.

To be able to execute the code, simply replace host and token variables in the examples. After replacing these two variables with your credentials, you will be able to try the standalone code examples as they are. We reccommend you work in non_production environment.

The standalone code examples look as follows:

from gooddata_sdk import GoodDataSdk

# GoodData base URL, e.g. "https://www.example.com"
host = "https://www.example.com"
# GoodData user token
token = "some_user_token"
sdk = GoodDataSdk.create(host, token)

workspace_id = "123"

# Read catalog for demo workspace
catalog = sdk.catalog_workspace_content.get_full_catalog(workspace_id)

# Print all dataset in the workspace
for dataset in catalog.datasets:
    print(dataset)

# Print all metrics in the workspace
for metric in catalog.metrics:
    print(metric)

# Read list of attributes for demo workspace
attributes = sdk.catalog_workspace_content.get_attributes_catalog(workspace_id)

# Read list of facts for demo workspace
facts = sdk.catalog_workspace_content.get_facts_catalog(workspace_id)

Snippet type

The snippet examples on the other hand are made to be small and quickly digestable. They do NOT contain import statements or variable initialization.

my_analytics_model = sdk.catalog_workspace_content.get_declarative_analytics_model("123")

# Modify the `CatalogDeclarativeAnalytics` object:
my_analytics_model.analytics.analytical_dashboards.clear()

# Put analytics model object back to the server:
sdk.catalog_workspace_content.put_declarative_analytics_model("123",my_analytics_model)