NAV
shell ruby python javascript

Thruxion - Communication API

API URL: http://thruxion.com:3001/api/

Communication API allows to register all kind of messages between senders and receivers (humans and/or machines). The channel is the platform where the message travel to its destiny if a noise is registered it can be add to the log. the code is about the language of the message and it can be asociated to senses. It's possible to register the date and time or the geo-location of the messages but it's optional.

Communication Diagram

The documenatation has a beta programming languages implementation of the API. currently it's possible to choose between Shell, Ruby, Python and JavaScript.

Authentication

To authorize, use this code:

require 'net/http'
require 'json'

uri = URI('http://thruxion.com:3001/api/login')
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
req.body = { username: 'admin', password: 'yourpassword' }.to_json

res = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }
puts res.body
import requests

url = "http://thruxion.com:3001/api/login"
data = {"username": "admin", "password": "yourpassword"}

response = requests.post(url, json=data)
print(response.json())  # Prints the token response
curl -X POST "http://thruxion.com:3001/api/login" \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "yourpassword"}'
const axios = require('axios');

const login = async () => {
    try {
        const response = await axios.post('http://thruxion.com:3001/api/login', {
            username: 'admin',
            password: 'yourpassword'
        });
        console.log(response.data);  // Prints the token response
    } catch (error) {
        console.error(error.response ? error.response.data : error.message);
    }
};

login();

Make sure to replace with your own API credentials.

The API uses JSON Web Tokens (JWT) for stateless authentication. Users authenticate by logging in with their username and password. Upon successful authentication, a JWT token is generated and returned. This token must then be included in the Authorization header of subsequent requests to access protected endpoints.

The authentication process involves two steps:

  1. Login: Submit your username and password to the /api/login endpoint to receive a JWT token { "username": "chetu", "password": "chetu2025" }

  2. Authenticated Requests: Include the JWT token in the Authorization header as Bearer for access to protected routes { "token": "eyJhbGcIU...I7MzBQ" }

HTTP Request

POST http://thruxion.com:3001/api/login

URL Parameters

Parameter Type
user string
password string

Communications CRUD

Add Communication

require 'net/http'
require 'json'
require 'uri'

uri = URI("https://thruxion.com:3001/api/communication")  # Updated URL to thruxion.com:3001
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json', 'Authorization' => 'Bearer YOUR_JWT_TOKEN')

# Example data to send
data = {
  sender: 'sender_name',
  receiver: 'receiver_name',
  message: 'Hello, this is a test message',
  channel: 'email',
  noise: 'low',
  code: '1234',
  feedback: 'positive',
  sense: 'clear'
}

req.body = data.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.body
import requests
import json

url = "https://thruxion.com:3001/api/communication"  # Updated URL to thruxion.com:3001
headers = {"Authorization": "Bearer YOUR_JWT_TOKEN", "Content-Type": "application/json"}

# Example data to send
data = {
    "sender": "sender_name",
    "receiver": "receiver_name",
    "message": "Hello, this is a test message",
    "channel": "email",
    "noise": "low",
    "code": "1234",
    "feedback": "positive",
    "sense": "clear"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())  # Prints the response message
curl -X POST "https://thruxion.com:3001/api/communication" \  # Updated URL to thruxion.com:3001
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "sender": "sender_name",
        "receiver": "receiver_name",
        "message": "Hello, this is a test message",
        "channel": "email",
        "noise": "low",
        "code": "1234",
        "feedback": "positive",
        "sense": "clear"
      }'
const axios = require('axios');

const addCommunication = async (data, token) => {
    try {
        const response = await axios.post('https://thruxion.com:3001/api/communication', data, {
            headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' }
        });
        console.log(response.data);  // Prints the response message
    } catch (error) {
        console.error(error.response ? error.response.data : error.message);
    }
};

// Example data to send
const data = {
    sender: 'sender_name',
    receiver: 'receiver_name',
    message: 'Hello, this is a test message',
    channel: 'email',
    noise: 'low',
    code: '1234',
    feedback: 'positive',
    sense: 'clear'
};

// Replace 'YOUR_JWT_TOKEN' with the actual token
addCommunication(data, 'YOUR_JWT_TOKEN');

The above command returns JSON structured like this:

[
    { 
        "id": 2,
        "message": "Communication record created successfully"
    }
]

This endpoint add a new communication.

HTTP Request

POST http://thruxion.com:3001/api/communication

Parameters

Parameter Default Description
sender not null who send the message
receiver not null who recieve the message
channel not null where the message travel
noise null possible interferences
code not null language of the message
message not null element exhanged
feedback not null response from the reciever
sense null senses involve in the message
longitude null geo-location (optional)
latitude null geo-location (optional)
date_time null when the message was sent
file_path null filepath where the message file is stored

Update Communication

require 'net/http'
require 'json'
require 'uri'

uri = URI("https://thruxion.com:3001/api/communication/COMMUNICATION_ID")  # Updated URL to thruxion.com:3001
req = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json', 'Authorization' => 'Bearer YOUR_JWT_TOKEN')

# Example data to update
data = {
  sender: 'updated_sender_name',
  receiver: 'updated_receiver_name',
  message: 'Updated message content',
  channel: 'phone',
  noise: 'medium',
  code: '5678',
  feedback: 'neutral',
  sense: 'unclear'
}

req.body = data.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.body
import requests
import json

url = "https://thruxion.com:3001/api/communication/COMMUNICATION_ID"  # Updated URL to thruxion.com:3001
headers = {"Authorization": "Bearer YOUR_JWT_TOKEN", "Content-Type": "application/json"}

# Example data to update
data = {
    "sender": "updated_sender_name",
    "receiver": "updated_receiver_name",
    "message": "Updated message content",
    "channel": "phone",
    "noise": "medium",
    "code": "5678",
    "feedback": "neutral",
    "sense": "unclear"
}

response = requests.put(url, headers=headers, json=data)
print(response.json())  # Prints the response message
curl -X PUT "https://thruxion.com:3001/api/communication/COMMUNICATION_ID" \  # Updated URL to thruxion.com:3001
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
        "sender": "updated_sender_name",
        "receiver": "updated_receiver_name",
        "message": "Updated message content",
        "channel": "phone",
        "noise": "medium",
        "code": "5678",
        "feedback": "neutral",
        "sense": "unclear"
      }'
const axios = require('axios');

const updateCommunication = async (id, data, token) => {
    try {
        const response = await axios.put(`https://thruxion.com:3001/api/communication/${id}`, data, {
            headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' }
        });
        console.log(response.data);  // Prints the response message
    } catch (error) {
        console.error(error.response ? error.response.data : error.message);
    }
};

// Example data to update
const data = {
    sender: 'updated_sender_name',
    receiver: 'updated_receiver_name',
    message: 'Updated message content',
    channel: 'phone',
    noise: 'medium',
    code: '5678',
    feedback: 'neutral',
    sense: 'unclear'
};

// Replace 'COMMUNICATION_ID' with the actual communication ID and 'YOUR_JWT_TOKEN' with the token
updateCommunication('COMMUNICATION_ID', data, 'YOUR_JWT_TOKEN');

The above command returns JSON structured like this:

{
    "message": "Communication record updated successfully"
}

This endpoint update an existing communication.

HTTP Request

PUT http://thruxion.com:3001/api/communication/<ID>

Parameters

Parameter Default Description
sender not null who send the message
receiver not null who recieve the message
channel not null where the message travel
noise null possible interferences
code not null language of the message
message not null element exhanged
feedback not null response from the reciever
sense null senses involve in the message

Get All Communications

require 'net/http'
require 'json'
require 'uri'

uri = URI('https://thruxion.com:3001/api/communication')  # Updated URL to thruxion.com
req = Net::HTTP::Get.new(uri, 'Authorization' => 'Bearer YOUR_JWT_TOKEN')

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.body
import requests

url = "https://thruxion.com:3001/api/communication"  # Updated URL to thruxion.com
headers = {"Authorization": "Bearer YOUR_JWT_TOKEN"}

response = requests.get(url, headers=headers)
print(response.json())  # Prints all communications
curl "https://thruxion.com:3001/api/communication" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
const axios = require('axios');

const getAllCommunications = async (token) => {
    try {
        const response = await axios.get('https://thruxion.com:3001/api/communication', {
            headers: { Authorization: `Bearer ${token}` }
        });
        console.log(response.data);  // Prints all communications
    } catch (error) {
        console.error(error.response ? error.response.data : error.message);
    }
};

// Replace 'YOUR_JWT_TOKEN' with the actual token
getAllCommunications('YOUR_JWT_TOKEN');

The above command returns JSON structured like this:

[
    {
        "id": 1,
        "sender": "UserA",
        "receiver": "UserB",
        "channel": "Email",
        "noise": "spam",
        "code": "Spanish",
        "message": "Hello, how are you?",
        "feedback": "Sent",
        "sense": "Visual",
        "date_time": "2024-02-13T12:00:00.000Z",
        "file_path": ""
    },
    {
        "id": 2,
        "sender": "Alice",
        "receiver": "Bob",
        "channel": "Zoom",
        "noise": "None",
        "code": "English",
        "message": "Meeting file",
        "feedback": "Finished",
        "sense": "Audiovisual",
        "date_time": "2025-02-18T15:30:00.000Z",
        "file_path": "/video/call.mp4"
    }
]

This endpoint retrieves all communications.

HTTP Request

GET http://thruxion.com:3001/api/communication

Get a Communication by ID

require 'net/http'
require 'json'
require 'uri'

communication_id = '1'  # Replace with the ID of the communication you want to fetch
uri = URI("https://thruxion.com:3001/api/communication/#{communication_id}")  # Updated URL to thruxion.com:3000
req = Net::HTTP::Get.new(uri, 'Authorization' => 'Bearer YOUR_JWT_TOKEN')

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.body
import requests

communication_id = '1'  # Replace with the ID of the communication you want to fetch
url = f"https://thruxion.com:3001/api/communication/{communication_id}"  # Updated URL to thruxion.com:3000
headers = {"Authorization": "Bearer YOUR_JWT_TOKEN"}

response = requests.get(url, headers=headers)
print(response.json())  # Prints the communication record
curl "https://thruxion.com:3001/api/communication/1" \  # Replace '1' with the actual communication ID
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
const axios = require('axios');

const getCommunicationById = async (id, token) => {
    try {
        const response = await axios.get(`https://thruxion.com:3001/api/communication/${id}`, {
            headers: { Authorization: `Bearer ${token}` }
        });
        console.log(response.data);  // Prints the communication record
    } catch (error) {
        console.error(error.response ? error.response.data : error.message);
    }
};

// Replace '1' with the actual communication ID and 'YOUR_JWT_TOKEN' with the actual token
getCommunicationById('1', 'YOUR_JWT_TOKEN');

The above command returns JSON structured like this:

{
        "id": 2,
        "sender": "Alice",
        "receiver": "Bob",
        "channel": "Zoom",
        "noise": "None",
        "code": "English",
        "message": "Meeting file",
        "feedback": "Finished",
        "sense": "Audiovisual",
        "date_time": "2025-02-18T15:30:00.000Z",
        "file_path": "/video/call.mp4"
}

This endpoint retrieves a specific communication.

HTTP Request

GET http://thruxion.com:3001/api/communication/<ID>

Parameters

Parameter Description
ID Communicaton ID

Delete Communication

require 'net/http'
require 'json'
require 'uri'

uri = URI('http://thruxion.com:3001/api/communication/1')  # Replace '1' with the ID of the record you want to delete
req = Net::HTTP::Delete.new(uri, 'Authorization' => 'Bearer YOUR_JWT_TOKEN')

res = Net::HTTP.start(uri.hostname, uri.port) { |http| http.request(req) }
puts res.body
import requests

url = "http://thruxion.com:3001/api/communication/1"  # Replace '1' with the ID of the record you want to delete
headers = {"Authorization": "Bearer YOUR_JWT_TOKEN"}

response = requests.delete(url, headers=headers)
print(response.json())  # Prints the response after deletion
curl -X DELETE "http://thruxion.com:3001/api/communication/1" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
const axios = require('axios');

const deleteCommunication = async (id, token) => {
    try {
        const response = await axios.delete(`http://thruxion.com:3001/api/communication/${id}`, {
            headers: { Authorization: `Bearer ${token}` }
        });
        console.log(response.data);  // Prints the response after deletion
    } catch (error) {
        console.error(error.response ? error.response.data : error.message);
    }
};

// Replace '1' with the ID and 'YOUR_JWT_TOKEN' with the actual token
deleteCommunication(1, 'YOUR_JWT_TOKEN');

The above command returns JSON structured like this:

{
    "message": "Communication record deleted successfully"
}

This endpoint deletes a specific communication.

HTTP Request

DELETE http://thruxion.com:3001/api/communication/<ID>

Parameters

Parameter Description
ID Communication ID

Errors

The Communication API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The kitten requested is hidden for administrators only.
404 Not Found -- The specified kitten could not be found.
405 Method Not Allowed -- You tried to access a communication with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
410 Gone -- The communication requested has been removed from our servers.
429 Too Many Requests -- You're requesting too many communications! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.