NAV
shell ruby php python javascript

Introduction

Welcome to the LeapBox API!

Authentication

Include your API key every request.

In order to obtain your API key, create an account.

Chat

Initialise new conversation

require "uri"
require "json"
require "net/http"

url = URI("https://api.leapbox.ai/api/chat/create")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
data = {
  'api_key' => '<API_KEY>',
  'conv_id' => '<CONV_ID>',
  'name' => 'name',
  'email' => '[email protected]',
  'manual_mode' => 0,
  'is_top' => false,
}
request.body = data.to_json

response = https.request(request)
puts response.read_body
<?php

require 'vendor/autoload.php'; // Adjust this based on your project structure and installation method

use GuzzleHttp\Client;

// Instantiate the Guzzle HTTP client
$client = new Client();

// Request URL
$url = "https://api.leapbox.ai/api/chat/create";

// Request parameters
$data = array(
    'api_key' => '<API_KEY>',
    'conv_id' => '<CONV_ID>',
    'conv_name' => '<CONV_NAME>',
    'name' => 'name',
    'email' => '[email protected]',
    'manual_mode' => 0,
    'is_top' => false,
);

try {
    // Send a POST request
    $response = $client->post($url, [
        'json' => $data
    ]);

    // Handle the response
    $statusCode = $response->getStatusCode();
    $responseData = $response->getBody()->getContents();

    if ($statusCode == 200) {
        // Request successful
        // Process the response data
        // ...
    } else {
        // Request failed
        echo "Request failed";
    }
} catch (Exception $e) {
    // Exception occurred
    echo "Exception occurred: " . $e->getMessage();
}

?>
import requests

url = "https://api.leapbox.ai/api/chat/create"

data = {
  api_key: "<API_KEY>",
  conv_id: "<CONV_ID>",
  conv_name: "<CONV_NAME>",
  name: 'name',
  email: '[email protected]',
  manual_mode: 0,
  is_top: false,
}

headers = {
   'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, json=data)

print(response.text)
curl -X 'POST' \
  'https://api.leapbox.ai/api/chat/create' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "api_key": "<API_KEY>",
  "conv_id": "<CONV_ID>",
  "conv_name": "<CONV_NAME>",
  "name": 'name',
  "email": '[email protected]',
  "manual_mode": 0,
  "is_top": false,
}'
const customHeaders = new Headers();
customHeaders.append("Content-Type", "application/json");

const data = {
  api_key: "<API_KEY>",
  conv_id: "<CONV_ID>",
  conv_name: "<CONV_NAME>",
  name: "name",
  email: "[email protected]",
  manual_mode: 0,
  is_top: false,
};

const resquestOptions = {
  method: "POST",
  headers: customHeaders,
  body: JSON.stringify(data),
};

fetch("https://api.leapbox.ai/api/chat/create", resquestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.log("error", error));

The above command returns JSON structured like this:

{
  "conv_id": "abcdef",
  "created_time": "2023-08-21T11:09:17.495085",
  "project_id": "abcdef123456",
  "user_id": "user123456"
}

conv_id is an optional parameter. Request which does not contain conv_id starts a new conversation and newly-generated conv_id is returned.

Associate conv_id with your particular user to maintain conversation context across time and multiple user interactions.

This endpoint performs a single conversation exchange.

HTTP Request

POST https://api.leapbox.ai/api/chat/create

Query Parameters

Parameter Type Default Description
api_key string - Create an account and subscribe to obtain your API key.
conv_id string Optional - Identify a particular conversation/user.
conv_name string Optional - conversation name
name string Optional - user name
email string Optional - user email
manual_mode number Optional 0 '0': Answered by AI. '1': Manual intervention
is_top boolean Optional false If true, conversation history will be at the top of the list.

Update conversation

require "uri"
require "json"
require "net/http"

url = URI("https://api.leapbox.ai/api/chat/update")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
data = {
  'api_key' => '<API_KEY>',
  'conv_id' => '<CONV_ID>',
  'name' => 'name',
  'email' => '[email protected]',
  'manual_mode' => 0,
  'is_top' => false,
}
request.body = data.to_json

response = https.request(request)
puts response.read_body
<?php

require 'vendor/autoload.php'; // Adjust this based on your project structure and installation method

use GuzzleHttp\Client;

// Instantiate the Guzzle HTTP client
$client = new Client();

// Request URL
$url = "https://api.leapbox.ai/api/chat/update";

// Request parameters
$data = array(
    'api_key' => '<API_KEY>',
    'conv_id' => '<CONV_ID>',
    'name' => 'name',
    'email' => '[email protected]',
    'manual_mode' => 0,
    'is_top' => false
);

try {
    // Send a POST request
    $response = $client->post($url, [
        'json' => $data
    ]);

    // Handle the response
    $statusCode = $response->getStatusCode();
    $responseData = $response->getBody()->getContents();

    if ($statusCode == 200) {
        // Request successful
        // Process the response data
        // ...
    } else {
        // Request failed
        echo "Request failed";
    }
} catch (Exception $e) {
    // Exception occurred
    echo "Exception occurred: " . $e->getMessage();
}

?>
import requests

url = "https://api.leapbox.ai/api/chat/update"

data = {
  api_key: "<API_KEY>",
  conv_id: "<CONV_ID>",
  name: "name",
  email: '[email protected]',
  manual_mode: 0,
  is_top: false
}

headers = {
   'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, json=data)

print(response.text)
curl -X 'POST' \
  'https://api.leapbox.ai/api/chat/update' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "api_key": "<API_KEY>",
  "conv_id": "<CONV_ID>",
  "name": "name",
  "email": "[email protected]",
  "manual_mode" 0,
  "is_top" false
}'
const customHeaders = new Headers();
customHeaders.append("Content-Type", "application/json");

const data = {
  api_key: "<API_KEY>",
  conv_id: "<CONV_ID>",
  name: "name",
  email: "[email protected]",
  manual_mode: 0,
  is_top: false,
};

const resquestOptions = {
  method: "POST",
  headers: customHeaders,
  body: JSON.stringify(data),
};

fetch("https://api.leapbox.ai/api/chat/update", resquestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.log("error", error));

The above command returns JSON structured like this:

{
  "conv_id": "abcdef",
  "created_time": "2023-08-21T11:09:17.495085",
  "project_id": "abcdef123456",
  "user_id": "user123456"
}

conv_id is an required parameter..

Associate conv_id with your particular user to maintain conversation context across time and multiple user interactions.

This endpoint performs a single conversation exchange.

HTTP Request

POST https://api.leapbox.ai/api/chat/update

Query Parameters

Parameter Type Default Description
api_key string - Create an account and subscribe to obtain your API key.
conv_id string - Identify a particular conversation/user.
name string Optional - user name
email string Optional - user email
manual_mode number Optional 0 '0': Answered by AI. '1': Manual intervention
is_top boolean Optional false If true, conversation history will be at the top of the list.

Send message to AI

require "uri"
require "json"
require "net/http"

url = URI("https://api.leapbox.ai/api/chat")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
data = {
  'api_key' => '<API_KEY>',
  'conv_id' => '<CONV_ID>',
  'text' => 'Hello!'
}
request.body = data.to_json

response = https.request(request)
puts response.read_body
<?php

require 'vendor/autoload.php'; // Adjust this based on your project structure and installation method

use GuzzleHttp\Client;

// Instantiate the Guzzle HTTP client
$client = new Client();

// Request URL
$url = "https://api.leapbox.ai/api/chat";

// Request parameters
$data = array(
    'api_key' => '<API_KEY>',
    'conv_id' => '<CONV_ID>',
    'text' => 'Hello!'
);

try {
    // Send a POST request
    $response = $client->post($url, [
        'json' => $data
    ]);

    // Handle the response
    $statusCode = $response->getStatusCode();
    $responseData = $response->getBody()->getContents();

    if ($statusCode == 200) {
        // Request successful
        // Process the response data
        // ...
    } else {
        // Request failed
        echo "Request failed";
    }
} catch (Exception $e) {
    // Exception occurred
    echo "Exception occurred: " . $e->getMessage();
}

?>
import requests

url = "https://api.leapbox.ai/api/chat"

data = {
  api_key: "<API_KEY>",
  conv_id: "<CONV_ID>",
  text: "Hello!",
}

headers = {
   'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, json=data)

print(response.text)
curl -X 'POST' \
  'https://api.leapbox.ai/api/chat' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "api_key": "<API_KEY>",
  "conv_id": "<CONV_ID>",
  "text": "Hello!"
}'
const customHeaders = new Headers();
customHeaders.append("Content-Type", "application/json");

const data = {
  api_key: "<API_KEY>",
  conv_id: "<CONV_ID>",
  text: "Hello!",
};

const resquestOptions = {
  method: "POST",
  headers: customHeaders,
  body: JSON.stringify(data),
};

fetch("https://api.leapbox.ai/api/chat", resquestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.log("error", error));

The above command returns JSON structured like this:

{
  "conv_id": "abcdef",
  "text": "Hey there!"
}

Say something to the AI and receive a response.

When conv_id is provided, the corresponding conversation (by a particular user) will be continued. If no matching conversation for given conv_id is found conv_id does not exist error is returned.

HTTP Request

POST https://api.leapbox.ai/api/chat

URL Parameters

Parameter Type Default Description
api_key string - Create an account and subscribe to obtain your API key.
conv_id string - Identify a particular conversation/user.
text string - User input message.

Get conversation histories

require "uri"
require "json"
require "net/http"

url = URI("https://api.leapbox.ai/api/chat/conversation/histories")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
data = {
  'api_key' => '<API_KEY>',
  'conv_id' => '<CONV_ID>',
}
request.body = data.to_json

response = https.request(request)
puts response.read_body
<?php

require 'vendor/autoload.php'; // Adjust this based on your project structure and installation method

use GuzzleHttp\Client;

// Instantiate the Guzzle HTTP client
$client = new Client();

// Request URL
$url = "https://api.leapbox.ai/api/conversation/histories";

// Request parameters
$data = array(
    'api_key' => '<API_KEY>',
    'conv_id' => '<CONV_ID>',
);

try {
    // Send a GET request
    $response = $client->get($url, [
        'json' => $data
    ]);

    // Handle the response
    $statusCode = $response->getStatusCode();
    $responseData = $response->getBody()->getContents();

    if ($statusCode == 200) {
        // Request successful
        // Process the response data
        // ...
    } else {
        // Request failed
        echo "Request failed";
    }
} catch (Exception $e) {
    // Exception occurred
    echo "Exception occurred: " . $e->getMessage();
}

?>
import requests

url = "https://api.leapbox.ai/api/conversation/histories"

data = {
  api_key: "<API_KEY>",
  conv_id: "<CONV_ID>",
}

headers = {
   'Content-Type': 'application/json'
}

response = requests.get(url, headers=headers, json=data)

print(response.text)
curl -X 'GET' \
  'https://api.leapbox.ai/api/conversation/histories' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "api_key": "<API_KEY>",
  "conv_id": "<CONV_ID>",
}'
const customHeaders = new Headers();
customHeaders.append("Content-Type", "application/json");

const data = {
  api_key: "<API_KEY>",
  conv_id: "<CONV_ID>",
  text: "Hello!",
};

const resquestOptions = {
  method: "GET",
  headers: customHeaders,
};

fetch(
  `https://api.leapbox.ai/api/conversation/histories?${new URLSearchParams(
    data
  ).toString()}`,
  resquestOptions
)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.log("error", error));

The above command returns JSON structured like this:

{
  "question": "hello!",
  "id": 1111,
  "project_id": "1ca14f5d0dd92f56f85b9e37fa5",
  "name": "name",
  "user_id": "f3b5c86a0deb833ff5c453f23587",
  "answer": "Hey there!",
  "chat_time": "2023-09-25T18:45:04.918422",
  "conv_id": "lfTaVr",
  "email": "[email protected]"
}

Provide conv_id to get conversation histories.

HTTP Request

POST https://api.leapbox.ai/api/conversation/histories

URL Parameters

Parameter Type Default Description
api_key string - Create an account and subscribe to obtain your API key.
conv_id string - Identify a particular conversation/user.

Errors

The LeapBox API uses the following error codes:

Error Code Meaning
40001 Failed Request -- described in detail in the msg field.
40002 Unauthorized -- Your API key is wrong.
50000 Too Many Requests -- You're tokens have been exhausted!