API

API Documentation

API Documentation for XOKind AI platform

Data Source

Data sources define the base data an app would use to train on. The data sources API provides a way to Create, Update, Query and Describe a data source and we currently support CSV, snowflake and raw row data. A data source is represented by an ID & a version ID. Data sources are immutable by nature, so any update operation on a data source changes the Version ID of the data source, keeping the ID same.

App

An app is an instance of a specific ML task. We currently support Lead Scoring, Image classification & NL2SQL ML tasks as instances of an App with more coming soon. The App API also provides a way to Create, Update, Describe, Fine Tune, Deploy and perform Inference on an app. An app is represented by an ID & a version ID. Each app needs a data source and app related metadata during creation. 

Instance of an app can then be fine tuned on the data source specified during creation. Deploy call deploys the particular app which should be ready for inference and can be performed using the Inference operation.

Security

Each API call can be invoked using an API Token which you can obtain by emailing us at ai@xokind.com.

Example

The first example describes a way to use a CSV file stored in a cloud data store (selected from here) as a data source for a lead scoring app which is prepared for performing real time inference on that specific dataset.

API

1. First step is to create a data source:

import requests

import json

url = "https://api.xokind.com/v1/data"

payload = {

   "details": {

       "csv": {

           "Url": "s3://foo/bank-addition.csv"

           }

       },

   "name": "Example"

}

headers = {

   "authorization": "bearer <api_token>"

}

response = requests.request("POST", url, headers=headers, data = json.dumps(payload))

data_source = response.json()

print(data_source['id'])

print(data_source['versionID'])

The call creates a data source and returns its ID/Version ID.

2. Use that data source ID to create an app choosing the output column as “y” from the underlying data source:

import requests

import json

url = "https://api.xokind.com/v1/app"

payload = {

   "dataSourceID": "<data_source_id>",

   "details": {

       "tabularDataScoring": {

           "inputColumnsIgnore": [],

           "outputColumns": [

               "y"

           ]

       }

   },

   "name": "Sample app"

}

headers = {

   "authorization": "bearer <api_token>"

}

response = requests.request("POST", url, headers=headers, data=json.dumps(payload))

app = response.json()

print(app['id'])

print(app['versionID'])

3. Once an app is created, fine tune the app using the underlying data source:

import requests

import json

url = "https://api.xokind.com/v1/fine_tune"

payload = {

   "tabularDataScoring": {

       "id": "<app_id>",

       "timeLimit": 20,

       "versionID": "<app_version_id>",

       "preset": "FASTEST"

   }

}

headers = {

   "authorization": "bearer <api_token>"

}

response = requests.request("POST", url, headers=headers, data=json.dumps(payload))

fine_tune_response = response.json()

print(fine_tune_response)

print(fine_tune_response['accuracy'])

print(fine_tune_response['featureImportanceScore'])

Currently we support a few presets and configurations which can be viewed in the documentation here.

4. Deploy the app once ready:

import requests

import json

url = "https://api.xokind.com/v1/app/<app_id>/<app_version_id>/deploy"

payload = {}

headers = {

   "authorization": "bearer <api_token>"

}

response = requests.request("POST", url, headers=headers, data=json.dumps(payload))

5. The app is ready for performing live inference requests:

import requests

import json

url = "https://api.xokind.com/v1/inference"

payload = {

   "tabularDataScoring": {

       "data": [

           {

               "data": {

                   "age": "30",

                   "job": "blue-collar",

                   "marital": "married",

                   "education": "basic.9y",

                   "default": "no",

                   "housing": "yes",

                   "loan": "no",

                   "contact": "cellular",

                   "month": "may",

                   "day_of_week": "fri",

                   "duration": "487",

                   "campaign": "2",

                   "pdays": "999",

                   "previous": "0",

                   "poutcome": "nonexistent",

                   "emp.var.rate": "-1.8",

                   "cons.price.idx": "92.893",

                   "cons.conf.idx": "-46.2",

                   "euribor3m": "1.313",

                   "nr.employed": "5099.1"

               }

           }

       ],

       "id": "<app_id>"

   }

}

headers = {

   "authorization": "bearer <api_token>"

}

response = requests.request("POST", url, headers=headers, data=json.dumps(payload))

inference_response = response.json()

print(inference_response['tabularDataScoring']['predictedClass'][0])

If you have any questions regarding the XOKind API, contact our team for additional information.

XOKind Team
Verified writer
Need help defining your AI project?

Book a 15-min consultation with an AI expert to identify the best use cases for your business.

BOOK CONSULTATION
OUT-OF-THE-BOX AI

Turn your data into predictive insights in record time