API CALLS inside DSS

Options
Sid
Sid Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 2 Partner

Can anyone help me in understanding how to perform API Calling inside DSS? How do i create an API call to fetch data from an external source ?

Answers

  • Ignacio_Toledo
    Ignacio_Toledo Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 411 Neuron
    Options

    To what kind of API do you want to connect? We've working with Jira and Smartsheet api calls, and our approach has two steps: first, we use the python SDK available, and we implement the calls that we want to use; second, if there are some "often used" API calls, we convert those codes into a Plugin.

    Does this describe and/or answer your question? If so, I could share some examples we have.

    Cheers

  • Sid
    Sid Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 2 Partner
    Options

    Hi ! Thank you so much for your response, basically we want to extract data from PEGA and bring into DataIKU using API calls and plugins . Do you have any examples pertaining to this?

  • Ignacio_Toledo
    Ignacio_Toledo Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 411 Neuron
    Options

    I do have some examples, but with Jira and Smartsheet APIs. Would this help you?

    Also, there is this other ticket in the community, where they provide an example, but for Freshdesk.

    Cheers.

  • ak12
    ak12 Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2022, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant Posts: 7 Neuron
    Options

    Hello,

    Not the original poster but I'm trying to connect to the smartsheet API within DSS and I was wondering if you'd be willing to share your example?

    Thanks!

  • Ignacio_Toledo
    Ignacio_Toledo Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 411 Neuron
    edited July 17
    Options

    Hi @ak12

    So, to connect to the smartsheet API you need first:

    • An access token to the API (documentation here)
    • A python environment with the smartsheet SDK installed (smartsheet-python-sdk)

    To connect to the smartsheet API, from a python notebook or recipe:

    import smartsheet
    # You need a Token to authenticate with smartsheet
    
    TOKEN = dataiku.get_custom_variables()['SMARTSHEET_TOKEN'] # we store the token in a custom variable in our DSS instance, but you should change this by the string token
    
    smartsheet_client = smartsheet.Smartsheet(TOKEN)
    smartsheet_client.errors_as_exceptions(True)

    This creates a client that we can use to interact with the sheets, and depending in your token permissions, you can add, update or delete sheets using code. You should start with the tutorial to understand the logic of the api.

    But let's say you want to get a sheet as a pandas dataframe, first you need the sheet id, that you can get online from the smartsheet webapp, or by listing all the sheets and their ids:

    sheets = smartsheet_client.Sheets.list_sheets(include_all=True)
    for s in sheets.data:
        print(f"The sheet \"{s.name}\" has id {s.id}")

    Once you have find the id of sheet you need, you should create a python function to automate the parsing into a dataframe:

    def simple_sheet_to_dataframe(sheet):
        col_names = [col.title for col in sheet.columns]
        rows = []
        for row in sheet.rows:
            cells = []
            for cell in row.cells:
                cells.append(cell.value)
            rows.append(cells)
        data_frame = pd.DataFrame(rows, columns=col_names)
        return data_frame

    Now we open the connection to the sheet on interest and parse the data into a dataframe:

    sheet = smartsheet_client.Sheets.get_sheet(id) # id can be a string or an int
    df = simple_sheet_to_dataframe(sheet)
    df.head() # to inspect the header

    In the previously linked tutorial you should find examples on how to read excel files and then insert them into smartsheet.

    I hope this helps to start!

    I.

  • Gaurav
    Gaurav Dataiku DSS Core Designer, Registered Posts: 1
    Options

    Hi

    I want to know about segment analysis data extraction from Similarweb API

    Please guide me

  • hauwasalisu
    hauwasalisu Registered Posts: 2
    Options

    API calls inside DSS can be a bit tricky at first, but once you get the hang of it, it's super powerful!

    To create an API call and fetch data from an external source, you'll need to use DSS's API connector. You can find a step-by-step guide on how to do this here.

    If you have any specific questions or run into issues, feel free to ask - the community here is super helpful, and we're all in this together!

Setup Info
    Tags
      Help me…