Domo library for python?

Hi All,

 

Is there a way to use domo library with python?

 

Thanks

 

Hiba

Best Answer

  • btm
    btm Domo Employee
    Answer ✓

    @evanbench & @user08715  

     

    We're excited to let you know the Python SDK is currently in Beta.

     

    Here are some instructions on how to access: Click Here

     

    Please feel free to leverage it and let us know if you have any feedback/questions.

     

    Thanks!

Answers

  • KaLin
    KaLin Member

    Can anyone help with this request?

  • evanbench
    evanbench Domo Employee

    Anyone know status of the Python libraries for Domo?

     

    Thanks,

     

    Evan

  • btm
    btm Domo Employee
    Answer ✓

    @evanbench & @user08715  

     

    We're excited to let you know the Python SDK is currently in Beta.

     

    Here are some instructions on how to access: Click Here

     

    Please feel free to leverage it and let us know if you have any feedback/questions.

     

    Thanks!

  • Hi,

     

    Thanks for your response.

     

    I stil have another question:
    Would it be possible to query data with the java or python domo library? For now I can find only the export feature where we get all the data.

     

    Thanks

  • btm
    btm Domo Employee

    Great question @user08715.

     

    We are currently working on that exact functionality.  It will likely be some basic SQL type statements to begin with in the first phase.

     

    I'd love to hear any specific ways you'd like to be querying the data that we could look at incorporating.

     

    Thanks,

  • Thanks @btm,

     

    For now SQL seems a quiet good way to query our data.
    It would be great if we could have the 'order by', 'group by' and 'as' (for giving aliases, especially for aggregations) statements, because we need them and they are not working/existing in the JS library.

     

    Thanks,

     

    Hiba

  • btm
    btm Domo Employee

    @user08715,

     

    Great to hear.

     

    Okay let me pass this back to the team.  As we continue to get closer to having something available for you - I'll keep you posted.

     

    Thanks,

  • yz
    yz Member

    This would be a very important functionality for us as well. 

     

    One way we use domo-python-sdk for - is to have it to pull data into Jupyter Notebook (http://jupyter.org/) environment powered by Python data science libraries for interactive data mining and exploration or quick prototyping of data transformation workflows. Unfortunately having to export a whole dataset sometimes makes this approach inefficient, while at the same time there is no similar (to Jupyter) functionality within Domo itself. Being able to query datasets with domo-python-sdk would dramatically increase its usability and allow Domo to leverage the power of Python data science libraries. 

     

    @btm do you have an approximate ETA for querying functionality in domo-python-sdk? 

     

    Cheers,

    yz

  • TPug
    TPug Member

    Also interested in this!

  • Yes. It's called pydomo. You can find it here:

    https://github.com/domoinc/domo-python-sdk

  • Hey @yz,

     

    Did you get it to work? i am trying to pull data from domo using the domo sdk in jupyter notebooks but i keep receiving a error message saying "Domo is currently undergoing<br/> maintenance."

     

    Could you give me a hand? maybe send me a working template to pull data?

     

    I appreciate the help. 

  •  

    import logging
    from pydomo import Domo

    # Build an SDK configuration
    client_id = '<client_id>'
    client_secret = '<client_secret>'
    api_host = 'api.domo.com'
    logger_name = 'foo'
    log_level = logging.INFO

    # Create an instance of the SDK Client
    domo = Domo(client_id, client_secret, api_host=api_host, logger_name=logger_name, log_level=log_level)

    csv_file_path = r'C:\Users\anthony.garcia\Documents\DOMO\emailbounce.csv'
    include_csv_header = True
    csv_file = domo.datasets.data_export_to_file('<data set guid>',csv_file_path,include_csv_header)
    csv_file.close()
    domo.logger.info("Downloaded data as a file from DataSet {}".format('<data set guid>'))

    # Client ID and Client Secret - you can get these by following the instructions here: https://developer.domo.com/docs/authentication/quickstart-5
    # Data Set Guid is in the URL when you are looking at a data set i.e. https://<your company>.domo.com/datasources/<data set guid>/details/overview
    I just ran this script and it worked just fine. Where I put <data set guid> or <client secret> or <client id> you obviously have to cut and paste your own in between the quotes (with not <>'s).

    Hope this helps.

     

  • Hey @acgarcia21,

     

    Thanks for that code, but i am getting the same error that i was getting with a previous version of my code, its returning an html page saying: 

    Domo is currently undergoing<br/> maintenance.
  • I would contact support. Perhaps there is a switch that is keeping your DOMO API functionality from working. 

     

    I am assuming you correctly generated the client_id, client_secret, and dataset guid.

  • Hey @user08825

    I agree with @acgarcia21 - you may need to double-check your app credentials and scope at developer.domo.com

     

    For the template - below are my usual steps when accessing datasets from within Jupyter. 

    This includes samples of listing/filtering datasets and reading them into Pandas dataframe. 

    Considering nature of work in Jupyter I normally omit logging. 

     

    from io import StringIO
    from pandas import read_csv
    from pydomo import Domo

    # Set your credentials:
    domo_host = ""
    domo_id = ""
    domo_secret = ""
    domo_owner = ""

    client = Domo(domo_id, domo_secret, api_host=domo_host, use_https=True)
    datasets = client.datasets

    # Locate all datasets under your account:
    ds_lst = [ds for ds in datasets.list() if ds["owner"]["id"] == domo_owner]

    # or

    # Locate all datasets by a keyword:
    search_str = "sample"
    ds_lst = [ds for ds in datasets.list() if search_str in ds["name"].lower()]

    # Print selection so you can visually pick dataset you are after:
    ds_pr = [" | ".join([d["id"], str(d["rows"]), d["name"]]) for d in ds_lst]
    ds_pr
    # ["f9db1b10-8171-d6ca-da80e321 | 259 | AU - Sample",
    # 'a7dc0409-3f88-b24f-d5251230 | 1 | Sample App | data2',
    # '263c5ac3-2744-e43b-947cf568 | 6 | Sample App | data1']

    # Load one of the datasets by id:
    dd = datasets.data_export(dataset_id=ds_lst[0]["id"], include_csv_header=True)

    # Read it into Pandas dataframe:
    df = read_csv(StringIO(dd))

    # Store dataset into csv bypassing dataframe:
    csv_file_path = "sample_data.csv"
    include_csv_header = True
    csv_file = datasets.data_export_to_file(ds_lst[1]["id"], csv_file_path, include_csv_header)
    csv_file.close()

    Unfortunately domo-python-sdk does not allow filtering data on select so you have to be careful when accessing large datasets. 

     

    If anyone is into automated etl / data integration with Python + DOMO API - I have build this Docker image that can be used for packaging integration jobs: https://hub.docker.com/r/yurz/domo-etl/

     

      

  • @user03141  What is domo_owner in the below template? Is this an email? User ID? Username? I tried the three above and didn't get any hits in the ds_lst variable so my thinking is I have an incorrect domo_owner.

  • I encoutnered the same issue. The solution is to put your user ID in without the " ". Hope this helps!

This discussion has been closed.