Home Data Prep Q&A


Big News: we’ve moved to the DataRobot Community! Please keep your eye out for an email invitation to join us there. Refer to the We've Moved FAQ for a guide on how to use your existing Paxata Community account to login to our new home.

Visit the official Paxata Documentation portal for all of your doc needs.

Paxata REST API

I’m trying to retrieve the column information using the REST api using the following command

GET "https://<paxata host>/rest/library/data?version=-1&return=name,dataFileId,schema.name

I’m getting null values for the schema.name

But when I use this command I get the JSON array with the no null values

GET "https://<paxata host>/rest/library/data?version=-1&return=name,dataFileId,schema

 

How do I correct my syntax to get a tab delimited result back with no null values?

Answers

  • Hi @ginoroy

    1) Your call seems to be putting the dataFileID parameter in the wrong place(so you are going to have ALL of your datasets returned, which I am not sure is what you want). Also, according the documentation, you can specify a "return" parameter. (the only two valid parameters are dataFileID and version  (there is state and loginDomainId but you can ignore those)

    2) (to my knowledge) the response is usually a json response, so to get what you're after (the column names of a specific dataset), try the below code (this is in python, and it works):

    # import the libraries you'll needimport requestsfrom urllib3.exceptions import InsecureRequestWarningrequests.packages.urllib3.disable_warnings(InsecureRequestWarning)from requests.auth import HTTPBasicAuth
    
    # Setup your variables.
    paxata_token = "
  • Hi @ginoroy

    1) The rest call is not quite right, you are providing parameters (return) that are not valid. Also you need to provide dataFileId in a slightly different place.

    2) Paxata responses will mostly be in JSON format, so you will need to handle that. I have provided a working sample for you to use for your purpose:

    # import the libraries you'll need
    import requests
    from urllib3.exceptions import InsecureRequestWarning
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
    from requests.auth import HTTPBasicAuth

    # Setup your variables.
    paxata_token = "paste your token here"
    auth_token = HTTPBasicAuth("",paxata_token)  
    dataFileID = "pase the libraryId here"

    # Make the REST API Call
    url_request = (paxata_url + "/rest/library/data/"+str(dataFileID)+"/-1")
    my_response = requests.get(url_request,auth=auth_token , verify=False)
    if(my_response.ok):
        json_response = json.loads(my_response.content)
    else:
        print ("Something went wrong.")

    # Go into the Json file, to the schema and loop through the column names
    for column_name in json_response.get('schema'):
        print (column_name.get('name'))

    That should be it! (because of attachment restrictions, i was unable to provide the jupyter notebook)
Sign In or Register to comment.