Importing Data into DataRobot using REST API or Python

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing Data into DataRobot using REST API or Python

You can import data into DataRobot in a number of ways. You can do this with curl commands from the REST API or using our Python SDK.

There are 3 types of data sources that are supported by DataRobot.

  • Local FIle
  • URL
  • JDBC Connection

Once you have your data imported the next step is to build models. Learn how to build models here. You can find the full Python Client documentation here.

You can get the sample code for this workflow and snippets in DataRobot Community GitHub.

Import Data with REST API

From a Local File:

Requirements

  • api_key—find this in your profile within the platform
  • file_path—identify the path to the file you want to import

Request Code

 

 

curl \ 
-H "Authorization: Bearer YOUR_API_KEY" \ 
-H "Content-Type: multipart/form-data" \
-X POST \ 
-F 'file=@YOUR_FILE_PATH' \ 
https://app.datarobot.com/api/v2/projects/

 

 

Example Request

(cURL code sample--importing from file)

 

 

API_KEY=YOUR_KEY
FILE_PATH=~YOUR_PATH
DR_ENDPOINT=YOUR_DR_URL/api/v2/projects

curl -v \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: multipart/form-data" \
-X POST \
-F file=@$FILE_PATH \
$DR_ENDPOINT

 

 

From a URL:

Requirements

  • api_key—find this in your profile within the platform
  • url— enter the URL that leads to the data file

Request Code

 

 

curl -v \
-X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"url\": \"YOUR_DATA_FILE_URL\"}" \
https://app.datarobot.com/api/v2/projects

 

 

Example Request

(cURL code sample--importing from URL)

 

 

DATA_FILE_URL=https:/user/10k_diabetes_test.xlsx
API_KEY=YOUR_API_KEY
DR_ENDPOINT=YOUR_DR_URL/api/v2/projects/

curl -v \
-X POST \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "{\"url\": \"$DATA_FILE_URL\"}" \
$DR_ENDPOINT

 

 

From a JDBC Connection:

Requirements

  • api_key—find this in your profile within the platform
  • datasourceId—enter the datasourceId (ID of the datasource object)
  • user—username for database
  • password—password for database

Request Code

 

 

curl -v \
-X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \ 
--data '{"dataSourceId": "DATASOURCE_ID", "user": "DB_USERNAME", "password": "DB_PASSWORD"}' \ 
https://app.datarobot.com/api/v2/projects/

 

 

Example Request

 

 

API_KEY=YOUR_API_KEY
DATASOURCE_ID=YOUR_DATASOURCE_ID
DB_USERNAME=user
DB_PASSWORD=password
DR_ENDPOINT=YOUR_APP_URL/api/v2/projects/

curl -v \
-X POST \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \ 
--d "{\"dataSourceId\": \"$DATASOURCE_ID\", \"user\": \"$DB_USERNAME\", \"password\": \"$DB_PASSWORD\"}" \
$DR_ENDPOINT

 

 

Import Data using Python

From a Local File:

Requirements

  • API Key—profile in the platform.
  • Import DataRobot Package and be connected to DataRobot (learn here)
  • filepath—path to the data file
  • project_name—name you want to assign to the project

Code

 

 

import datarobot as dr

dr.Client(token='YOUR_API_KEY', 
          endpoint='https://app.datarobot.com/api/v2')
project = dr.Project.create('<filepath>', project_name='<project name>') 

 

 

Example

(Python code sample--importing from file)

 

 

import datarobot as dr

dr.Client(token='YOUR_API_KEY', 
          endpoint='https://app.datarobot.com/api/v2')

project = dr.Project.create('/Users/Desktop/10k_diabetes.csv', project_name='Diabetes') 

 

 

Labels (3)
Version history
Revision #:
22 of 22
Last update:
2 weeks ago
Updated by:
 
Contributors