Welcome to the API documentation for our chatbot application. Here, you will find all the information you need to interact with our API and build chatbots for your application. Our API provides endpoints for creating, deleting, and sending messages to chatbots, as well as listing all the chatbots associated with your account.
The login endpoint allows you to authenticate your account and receive an access token that is used to authorize your subsequent requests. To authenticate, you must provide your username and API key in the request body. You can get your api key from accounts page. If the authentication is successful, you will receive an access token (JWT Token) that you can use to access protected endpoints. If the authentication fails, you will receive an error message.
Method: POST
URL: /api/v1/login
Request body:
{ "username": "your_username", "api_key": "your_api_key" }
Status codes:
200
: Successful authentication400
: Invalid or missing parameters401
: Invalid username or API key407
: Service not availableResponse body:
{ "access_token": "your_access_token" }
import requests import json url = "https://fyran.site/api/v1/login" headers = { "Content-Type": "application/json" } data = { "username": "user@example.com", "api_key": "your_api_key" #get this from account page } response = requests.post(url, headers=headers, data=json.dumps(data)) if response.status_code == 200: print("Login Successful!") print("Access Token: ", response.json()['access_token']) else: print("Login Failed!") print("Error Message: ", response.json()['msg'])
<?php $url = 'https://fyran.site/api/v1/login'; $data = array('username' => 'user@example.com', 'api_key' => 'your_api_key'); $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); if ($http_response_header[0] == "HTTP/1.1 200 OK") { echo "Login Successful!"; $response = json_decode($result, true); echo "Access Token: ".$response['access_token']; } else { echo "Login Failed!"; $response = json_decode($result, true); echo "Error Message: ".$response['msg']; } ?>
The list chatbot endpoint returns a list of all chatbots associated with the logged-in user's account. To use this endpoint, an access token obtained from the login endpoint is required. The returned list contains the chatbot creation date, namespace, and status.Note: There is a rate limiting applied on this endpoint with maximum 5 requests per minute. To increase this, please contact support with your business use-case.
Method: GET
URL: /api/v1/list_chatbot
Headers:
{ "Authorization": "Bearer your_access_token" }
Status codes:
200
: Successful request401
: Unauthorized request407
: Service not availableResponse body:
{ "chatbots": [ { "created_at": "chatbot_creation_date", "namespace": "chatbot_namespace", "status": "chatbot_status" }, { "created_at": "chatbot_creation_date", "namespace": "chatbot_namespace", "status": "chatbot_status" }, ... ] }
import requests from requests.auth import HTTPBasicAuth # Define the URL url = "https://fyran.site/api/v1/list_chatbot" # Define the JWT token jwt_token = "your_jwt_token" # Define the headers for the request headers = { 'Authorization': f'Bearer {jwt_token}' } # Send the request response = requests.get(url, headers=headers) # Print the response print(response.json())
<?php require 'vendor/autoload.php'; use GuzzleHttp\Client; $client = new Client(); // Define the URL $url = "https://fyran.site/api/v1/list_chatbot"; // Define the JWT token $jwt_token = "your_jwt_token"; $response = $client->request('GET', $url, [ 'headers' => [ 'Authorization' => 'Bearer ' . $jwt_token, ] ]); $body = $response->getBody(); print_r(json_decode((string)$body, true)); ?>
The create chatbot endpoint allows you to create a chatbot associated with your account. The chatbot is created by uploading a file containing the content you want to use to train the chatbot, which can be in one of the following formats: .docx, .pdf, .txt, .mp3 or .mp4. The endpoint will extract the text from the file and use it to train a new chatbot with a unique namespace reference. The chatbot will be associated with your account and you can use it to respond to user queries.
Method: POST
URL: /api/v1/create_chatbot
Headers:
{ "Authorization": "Bearer your_access_token" }
Request body:
This endpoint requires a multipart/form-data request with the following parameters:
with open(file, 'rb') as f:
file_data = {'file': (os.path.basename(file), f)}
response = requests.post(/api/v1/create_chatbot, headers=headers, files=file_data)
file
: The file you want to use to train the chatbot. Must be a .docx, .pdf, .txt, .mp3, or .mp4 file.Status codes:
200
: Chatbot created successfully400
: Invalid or missing parameters401
: Unauthorized requestResponse body:
SUCCESS
: If the chatbot is created successfully, you will receive a JSON response with a success message and the namespace reference for the new chatbot.ERROR
: If there is an error creating the chatbot, you will receive a JSON response with an error message.Example:
{ "SUCCESS": "Chabot 'namespace_ref' created successfully." }
import requests, os url = 'https://fyran.site/api/v1/create_chatbot' headers = {'Authorization': f'Bearer {access_token}'} file_path = 'path_to_your_file' with open(file_path, 'rb') as f: files = {'file': (os.path.basename(file_path), f)} response = requests.post(url, headers=headers, files=files) print(response.json())
<?php require 'vendor/autoload.php'; use GuzzleHttp\Client; $client = new Client(); $url = "https://fyran.site/api/v1/create_chatbot"; $jwt_token = "your_jwt_token"; $file_path = 'path_to_your_file'; $response = $client->request('POST', $url, [ 'headers' => [ 'Authorization' => 'Bearer ' . $jwt_token, ], 'multipart' => [ [ 'name' => 'file', 'contents' => fopen($file_path, 'r') ] ] ]); $body = $response->getBody(); print_r(json_decode((string)$body, true)); ?>
The send message endpoint allows you to send a message to a chatbot associated with your account. To send a message, you must provide the chatbot namespace, the message/question, and an access token obtained from the login endpoint. The endpoint will return the chatbot's response along with the relevant paragraphs, credits used, and remaining credits.
Note: Refer to /api/v1/list_chatbot to get chatbot namespace.
Method: POST
URL: /api/v1/send_message
Headers:
{ "Authorization": "Bearer your_access_token" }
Request body:
{ "chatbot": "your_chatbot_namespace", "question": "your_question_message" }
Response
Status codes:
200
: Successful request400
: Invalid or missing parameters401
: Unauthorized request407
: Service not availableResponse body:
{ "chat_response": "response_message", "chat_time": "time_taken_in_seconds", "chat_relevant_paras": ["relevant_para1", "relevant_para2"], "rem_credits": "remaining_credits", "credits_used": "credits_used_for_the_request" }
import requests import json # Define the API endpoint url = "https://fyran.site/api/v1/send_message" # Define the headers for JWT auth headers = {"Authorization": f'Bearer {access_token}'} # Define the JSON body data = { "chatbot": "chatbot_name", #You can get this from dashboard activity window or chatbot URL "question": "your_question" } # Make the POST request to the Flask API response = requests.post(url, headers=headers, json=json_data) # Print the response print(response.json())
<?php // API URL $url = "https://fyran.site/api/v1/send_message"; // Data $data = array( 'chatbot' => 'chatbot_name', 'question' => 'your_question' ); // Headers $headers = array( 'Authorization: Bearer YOUR_JWT_TOKEN', 'Content-Type: application/json' ); // Initialize cURL $ch = curl_init($url); // Set the options curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); // Execute the cURL request $response = curl_exec($ch); // Close the cURL session curl_close($ch); // Output the response echo "Response: " . $response; ?>
The delete chatbot endpoint allows you to delete a chatbot associated with your account. To delete a chatbot, you must provide its namespace in the request body and an access token obtained from the login endpoint. If the deletion is successful, you will receive a success message. If the chatbot does not exist or the deletion fails, you will receive an error message.
Note: You can get the namespace of your chatbot from the /api/v1/list_chatbot api.
Method: POST
URL: /api/v1/delete_chatbot
Headers:
{ "Authorization": "Bearer your_access_token" }
Request body:
{ "chatbot": "your_chatbot_namespace" }
Status codes:
200
: Successful deletion400
: Invalid or missing parameters401
: Unauthorized request407
: Service not availableResponse body:
{ "message": "request_response_message" }
import requests from requests.auth import HTTPBasicAuth # Define the URL url = "https://fyran.site/api/v1/delete_chatbot" # Define the JWT token jwt_token = "your_jwt_token" # Define the chatbot namespace to delete namespace = "your_chatbot_namespace" #You can get this from either dashboard or using /list_chatbot API # Define the headers for the request headers = { 'Authorization': f'Bearer {jwt_token}' } # Send the request response = requests.post(url, headers=headers, json={'chatbot': namespace}) # Print the response print(response.json())
<?php require 'vendor/autoload.php'; use GuzzleHttp\Client; $client = new Client(); // Define the URL $url = "https://fyran.site/api/v1/delete_chatbot"; // Define the JWT token $jwt_token = "your_jwt_token"; // Define the chatbot namespace to delete $namespace = "your_chatbot_namespace"; $response = $client->request('POST', $url, [ 'headers' => [ 'Authorization' => 'Bearer ' . $jwt_token, ], 'json' => [ 'chatbot' => $namespace, ] ]); $body = $response->getBody(); print_r(json_decode((string)$body, true)); ?>