Sending Data


Before the Nexosis API can do anything really useful, you’re going to need to send it some data that it can use for Forecasts or Impact Analysis.


Datasets

You can send data to the Nexosis API through the Data endpoint.

Data can be sent to the Nexosis API as either JSON or CSV, with optional metadata


Examples

In this example we’ll create a Named DataSet called sales by sending some data to it.

`timestamp` is the date and time being observed and `values` are a dictionary of values observed at that time.

        
          curl -v -X PUT "https://ml.nexosis.com/v1/data/sales" \
          -H "Content-Type: application/json" \
          -H "api-key: {subscription key}" \
          --data-binary "@/path/to/file/data.json"
        
      
          
          {
            "data": [
              {
                "timestamp": "2017-05-25T00:00:00+00:00",
                "sales": 1000.0,
                "orders": 100
              },
              {
                "timestamp": "2017-05-26T00:00:00+00:00",
                "sales": 980.0,
                "orders": 98
              },
              {
                "timestamp": "2017-05-27T00:00:00+00:00",
                "sales": 1100.0,
                "orders": 110
              },
              {
                "timestamp": "2017-05-28T00:00:00+00:00",
                "sales": 1080.0,
                "orders": 108
              },
              {
                "timestamp": "2017-05-29T00:00:00+00:00",
                "sales": 1110.0,
                "orders": 111
              }
            ]
          }
          
      

TimeStamps

By default, the API will assume that the timestamp in your CSV DataSet is in a column named *timestamp*.

If your csv data has a timestamp with a different column name, you can provide that name with a parameter in the query string named *timestampColumn*

        
          curl -v -X PUT "https://ml.nexosis.com/v1/data/sales?timestampColumn=date" \
          -H "Content-Type: text/csv" \
          -H "api-key: {subscription key}" \
          --data-binary "@/path/to/file/data.csv"
        
      
          
          date,sales,orders
          2017-05-25,1000,100
          2017-05-26,980,98
          2017-05-27,1100,110
          2017-05-28,1080,108
          2017-05-29,1110,111
          
      

Response

The response to the PUT will be an HTTP 200 with a response body that is a summary of the DataSet.

{
  "dataSetName": "sales"
}

Updating Data

You can modify the DataSet with additional and/or updated data by issuing a PUT to the same DataSet name.

So, issuing a PUT to the same sales DataSet above like so

curl -v -X PUT "https://ml.nexosis.com/v1/data/sales?timestampColumn=date" \
-H "Content-Type: text/csv" \
-H "api-key: {subscription key}" \
--data-binary "@/path/to/file/data.csv"
date,sales,orders
2017-05-29,1120,112
2017-05-30,1234,123
2017-05-31,1235,123

Will result in the sales DataSet containing the following records:

2017-05-25,1000,100
2017-05-26,980,98
2017-05-27,1100,110
2017-05-28,1080,108
2017-05-29,1120,112
2017-05-30,1234,123
2017-05-31,1235,123

Where the timeStamp that overlapped between the first PUT and the second PUT overwrote the value from the first, and the non-overlapping timeStamps were appended.

   Data CSV JSON