ICDST AI Predict API Documentation

Overview

This API allows users to predict the next n numbers in a sequence of real numbers using a specified machine learning model. It supports multiple programming languages and provides detailed error handling.

Endpoint

POST https://icdst.org/API/

Parameters

Parameter Type Description Required
type string Must be set to "prediction". Yes
key string API key for authentication. Leave empty for free usage (up to 1000 tokens per 24 hours). No
model string Name of the model to use. If empty, the latest available model will be used. No
data JSON object Contains n (number of predictions) and numbers (array of real numbers). Yes

Responses

Status Code Response Description
200 {"message":"success!","result":["14","15"],"time":0,"tokens":992} Prediction successful. Includes predicted values and remaining tokens.
400 {"message":"Incomplete parameters!"} Missing or incomplete parameters.
400 {"message":"Invalid \"type\" parameter!"} type parameter is not set to "prediction".
400 {"message":"\"numbers\" parameter must be an array of real numbers!"} numbers parameter is invalid.
400 {"message":"Missing \"n\" parameter, or wrong type; \"n\" must be a positive integer!"} n parameter is missing or invalid.
401 {"message":"Invalid API key"} Invalid or unauthorized API key.
402 {"message":"Out of tokens! You need at least 6 more tokens to process this request.","tokens":5} User does not have enough tokens to process the request.

Code Examples

PHP


// Example usage
$data = [1, 2, 3, 4];
$n = 2;
$key = ''; // Free usage
$model_name = '';

// Validate input parameters
if (!is_array($data) || !is_numeric($n) || $n <= 0) {
    echo json_encode(['message' => 'Invalid input parameters']);
    exit;
}

// Prepare the payload
$payload = [
    'type' => 'prediction',
    'key' => $key,
    'model' => $model_name,
    'data' => json_encode(['n' => $n, 'numbers' => $data])
];

// Initialize cURL
$ch = curl_init('https://icdst.org/API/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

// Decode the JSON response into an array
$responseArray = json_decode($response, true);

// Print the response array
print_r($responseArray);


Python


import requests
import json

# Example usage
data = [1, 2, 3, 4]
n = 2
key = ''  # Free usage
model_name = ''

# Validate input parameters
if not isinstance(data, list) or not isinstance(n, (int, float)) or n <= 0:
    print(json.dumps({'message': 'Invalid input parameters'}))
else:
    # Prepare the payload
    payload = {
        'type': 'prediction',
        'key': key,
        'model': model_name,
        'data': json.dumps({'n': n, 'numbers': data})
    }

    # Execute the request
    response = requests.post('https://icdst.org/API/', data=payload)

    # Decode the JSON response into a dictionary
    response_dict = response.json()

    # Print the response dictionary
    print(response_dict)



cURL


curl -X POST https://icdst.org/API/ \
     -d "type=prediction" \
     -d "key=" \
     -d "model=" \
     -d "data={\"n\":5,\"numbers\":[1,2,3,4]}"