# Data Input (DP\_1)

{% hint style="warning" %}
**NOTE:** If you're using a database connection, create a separate user with appropriate permissions, before uploading data from a database.&#x20;
{% endhint %}

## Sample Request

```javascript
{
    "project_id": 1,
    "parent_id": 0,
    "block_id": 1,
    "function_code": "DP_1",
    "args": {
        "dburl": "https://raw.githubusercontent.com/autogonai/autogon-public-datasets/main/mobile_price_prediction.csv",
        "dbservertype": "",
        "file_type": "csv",
        "database_name": "",
        "dbuser": "",
        "dbpassword": "",
        "query": "",
    }
}
```

## Data input

<mark style="color:green;">`POST`</mark> `https://api.autogon.ai/api/v1/engine/start`

Loads data into a project.

#### Request Body

| Name                                                   | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ------------------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| dburl<mark style="color:red;">\*</mark>                | String | database host or Data Source URL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| file\_type<mark style="color:red;">\*</mark>           | String | File type for data input (`db` for database, `csv` for CSV, `json` for JSON for source files.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| dbservertype                                           | String | database server type (required with `file_type: db`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| database\_name                                         | String | Name of the database (required with `file_type`: `db)`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| dbuser                                                 | String | Username for connecting with database (required with `file_type`: `db)`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| dbpassword                                             | String | Password for connecting with the database (required with `file_type`: `db)`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| query                                                  | String | query to fetch data from the database (required with `file_type`: `db)`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| project\_id<mark style="color:red;">\*</mark>          | int    | current project ID                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| block\_id<mark style="color:red;">\*</mark>            | int    | current block ID                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| function\_code<mark style="color:red;">\*</mark>       | String | block's function code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| args<mark style="color:red;">\*</mark>                 | object | block arguments                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| parent\_id                                             | int    | previous block ID                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| method<mark style="color:red;">\*</mark>               | String | <p>Method of importation.</p><p><br><strong>Options:</strong><br></p><p>'<code>img\_class\_folder</code>': import as an image classification problem with folder names as image class labels<br><br>'<code>img\_csv</code>': import as an image regression or classification problem<br>with image paths listed in a colmn of a csv and target variables on other column(s)<br></p><p>(required with <code>file\_type</code> : <code>zip</code>)</p>                                                                                                                                                                                                                                                                                                                                  |
| images\_path                                           | String | <p>Path to images from zip file's root<br><br>(required with <code>file\_type</code>: <code>zip</code>)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| class\_mode                                            | String | <p>Method of importing target labels or variables<br><br><strong>Options:</strong><br></p><p>'<code>binary</code>': The inputter will return binary labels indicating the class membership of each sample<br><br>'<code>categorical</code>': The inputter will return one-hot encoded labels, where each class is represented by a binary vector with a single 1 and 0s elsewhere</p><p></p><p></p><p>'<code>sparse</code>': Instead of one-hot encoded labels for a multi-classifcation problem, the inputter will return integer labels for each class</p><p></p><p></p><p>'<code>input</code>': The inputter will return the input images as both the input and output.</p><p></p><p></p><p>'<code>raw</code>': The inputter will return the raw data gotten for the y\_column</p> |
| target\_size<mark style="color:red;">\*</mark>         | array  | <p>Image size in pixels (Length, Width)<br><br>(required with <code>file\_type</code>: <code>zip</code>)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| csv\_path<mark style="color:red;">\*</mark>            | String | <p>Path to CSV from zip file's root<br><br>(required with <code>file\_type</code>: <code>zip</code> and <code>method</code>: <code>img\_csv</code>)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| image\_files\_column<mark style="color:red;">\*</mark> | String | <p>Column name of column containing the list of image file names (images within folders aren't allowed)</p><p></p><p>(required with <code>file\_type</code>: <code>zip</code> and <code>method</code>: <code>img\_csv</code>)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| y\_columns                                             | array  | <p>Column names of columns containing target variable(s). Leave empty to include all other columns</p><p></p><p>(required with <code>file\_type</code>: <code>zip</code> and <code>method</code>: <code>img\_csv</code>)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

{% tabs %}
{% tab title="200: OK Data Input Successful" %}

```javascript
{
    "status": "true",
    "message": {
        "id": 1,
        "project": 2,
        "block_id": 1,
        "parent_id": 0,
        "dataset_url": "",
        "x_value_url": "",
        "y_value_url": ""
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Python" %}

```
// Some code
```

{% endtab %}

{% tab title="Node" %}

```javascript
await client.data_input(1, 0, 1, {
    dburl: "https://raw.githubusercontent.com/autogonai/autogon-public-datasets/main/mobile_price_prediction.csv" ,
    file_type: "csv"
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Good to know:** Unlike other block requests, the **Data Input** block isn't permitted to have parent blocks, hence its `null` value.
{% endhint %}
