Skip to content

API Docs

API Reference Guide

Apteo's API is available to users of our Pro tier and helps you manage your data and create predictions after you have created a predictive insight report. These docs will give you a general overview of how to use our API, but you can also find dataset-specific instructions on your team's workspace, within the Data tab, on each dataset's overview page.

Authentication

The Apteo API uses authentication keys to authenticate requests. You'll find your API key on your team's Settings tab.

Your API keys are the same as a password, make sure to keep them secure and to not share them in publicly accessible areas.

Authentication to the API is performed by using the header from your API request. Provide your API key as a key/value pair in your request's header, with the key "Authorization", and the value "Basic " (see example below).

import json 
import requests 

headers = {"Authorization": "Basic <YOUR_API_KEY>"} 
body = {"dataRows": [{
    "customer_gender": "Male", 
     "signup_date": "2020-01-03", 
     ... 
     "customer_score": 32.44 
 }]} 

response = requests.post(url = "<API_PATH>", 
             headers = headers, 
             data = json.dumps(body))

API Quotas

Professional-tier accounts are allowed 25,000 API requests per hour, and 10 million API requests per month. If you need higher limits, please contact us

Data Management

Datasets

Our API allows you to create a new dataset within your team's workspace. When you create a dataset, you will need to make a POST request to https://developers.apteo.co/api/v2/data-sources/create.

Create API Request

When using the API to create a data source, you will need to provide a a list of tables. Each table should have a name and a schema. To learn how to structure your request, you can see the example request. Support field types are provided below.

Auto Assign Row ID

Apteo can automatically assign a unique ID to each row by default, you can also mark autoAssignRowId as False to avoid this.

Example Request
import json 
import requests 

headers = {"Authorization": "Basic <YOUR_API_KEY>"} 
body = {"dataSourceName": "New Data Source"
    "tables": [{
        "tableName": "New Table 1", 
        "autoAssignRowId": True, 
        "schema": [{
            "fieldName": "Field 1", 
            "fieldType": "STRING", 
             "isNullable": True
        }, {
            "fieldName": "Field 2", 
            "fieldType": "INTEGER", 
             "isNullable": True 
        }]
    }, {
        "tableName": "New Table 2", 
        "autoAssignRowId:" False, 
        "schema": [{
            "fieldName": "Field 1", 
            "fieldType": "STRING", 
             "isNullable": True
        }, {
            "fieldName": "Field 2", 
            "fieldType": "INTEGER", 
             "isNullable": True 
        }]
    }] 
}  

response = requests.post(url = "<API_PATH>", 
             headers = headers, 
             data = json.dumps(body))
Example Response
{"dataSource": {
    "dataSourceId": 12412321
    "name": "New Data Source"
    "tables": [{
        "tableId:" "123231244", 
        "tableName:" "New Table Name", 
        "Table Schema": [{
            ...
        }],
        "apiPaths": {
            "apiPathForDataInsertion": {
                "description": "Use this API path in order to insert data into this table",
                "path": "<the_full_path_to_insert_data_into_this_table>",
            },
            "apiPathForDataUpdates": {
                "description": "Use this API path in order to update data rows in this table",
                "path": "<the_full_path_to_update_data_to_this_table>",
            },
            "apiPathForDataDeletion": {
                "description": "Use this API path in order to delete rows present in this table",
                "path": "<the_full_path_to_delete_data_from_this_table>",
            } 
        } 
    }] 
}}

Data Records

The Apteo API allows you to create, update, and delete records within an existing dataset.

Create Records

The CREATE API allows you to insert records into an existing dataset. You may insert a single record or multiple records with a single API request. Creating records requires a POST request to a URL that is specific to each dataset (i.e. https://developers.apteo.co/api/v2/data-connectors/<dataset ID>/insert)

When using the API to insert data - you will need to provide a list of JSON objects. Each JSON object should contain a value for each field. Values for individual fields can be null.

The list of fields for each object must match your table's schema. We provide you with a schema file for each table within your dataset's page on your team's workspace.

Example Request
import json 
import requests 

headers = {"Authorization": "Basic <YOUR_API_KEY>"} 
body = {"dataRows": [{
    "customer_gender": "Male", 
     "signup_date": "2020-01-03", 
     ... 
     "customer_score": 32.44 
 }]} 

response = requests.post(url = "<API_PATH>", 
             headers = headers, 
             data = json.dumps(body))
Example Response
{"dataInsertionSuccess": true, "dataRowsInserted": 123}

Update Records

The UPDATE API allows you to update records in an existing dataset. You may insert a single record or multiple records with a single API request. In order to determine which records to update, you must pass in a set of filters for which the matching records will be updated.

Updating a record requires a PATCH request to a URL that is specific to each dataset (i.e. https://developers.apteo.co/api/v2/data-connectors/<dataset ID>/update).

When using the API to update data, you will need to provide a list of json objects. Filter values cannot be null. Updated data can be null.

The list of fields for each object must match your table's schema. We provide you with a schema file for each table within your dataset's page on your team's workspace. Data updated via the API may take up to 5 minutes to show up on the product.

Example Request
import json 
import requests 

headers = {"Authorization": "Basic <YOUR_API_KEY>"} 
body = {"dataRows": [{
    "customer_gender": "Male", 
     "signup_date": "2020-01-03", 
     ... 
     "customer_score": 32.44 
 }]} 

response = requests.post(url = "<API_PATH>", 
             headers = headers, 
             data = json.dumps(body))
Example Response
{"dataRowsUpdated": 123}

Delete Records

The DELETE API allows you to remove records in an existing dataset. You may delete a single record or multiple records with a single API request. In order to determine which records to update, you must pass in a set of filters for which the matching records will be updated.

Deleting a record requires a PATCH request to a URL that is specific to each dataset (i.e. https://developers.apteo.co/api/v2/data-connectors/<dataset ID>/delete).

Example Request
import json 
import requests 

headers = {"Authorization": "Basic <YOUR_API_KEY>"} 
body = {"deleteFilters": {
     "userId": 2311, 
     "status": "PAID", 
     ... 
 }} 

response = requests.patch(url = "<API_PATH>", 
              headers = headers, 
              data = json.dumps(body))
Example Response
{"dataRowsDeleted": 123}

Predictions

When you create a predictive insight report, you can then use the resulting model to generate predictions via the API. In order to generate a prediction, you'll need to specify a list of JSON objects with a list of attribute names and their associated values. We provide you with a template that contains a mapping of attribute names to IDs. When making your request, you will need to use this list of attribute IDs to send the system the values that you would like it to use to make its predictions.

The system will use the values you provide, along with the predictive model that was generated when you created your predictive insight report, to provide you with a list of predicted values.

Creating predictions requires a POST request to a URL that is specific to each predictive model (i.e. https://developers.apteo.co/api/v2/predict/<predictor ID>). For each JSON object you send over, you will get a response that contains the values you sent and a prediction for each individual object.

Example Request
import json 
import requests 

headers = {"Authorization": "Basic <YOUR_API_KEY>"} 
body = {"addPredictionExplanation": False,
    "predictionsData": [{
    "feature_1": "Male", 
     "feature_2": "2020-01-03", 
     ... 
     "feature_32": 32.44 
 }]} 
response = requests.post("<API_PATH>", headers = headers, data = json.dumps(body))
Example Reponse
{"predictions": [
    "feature_1": "Male", 
     "feature_2": "2020-01-03", 
     ... 
     "feature_32": 32.44, 
     "prediction": 91.33 
]}