CALCULATE PRICE

Calculate Price API Endpoints

Complete documentation for all Calculate Price related endpoints.

POST

Calculate Price

Calculate service price based on hours and monthly price.

Endpoint Details

HTTP Request
POST https://0xhost.net/API/calculate_price
Parameters
Parameter Type Required Description
hours integer Yes Service hours
monthly_price float Yes Monthly price
renewal_date string No Renewal date (YYYY-MM-DD HH:MM:SS)
Authentication
API Key Required in header
Headers
Header Value Required Description
x-api-key your_api_key_here Yes Your unique API key for authentication
Content-Type application/json Optional Recommended for consistent response handling

Response Fields

Field Type Description
success boolean Indicates if the operation was successful
message string Response message describing the result
data object/array Contains the response data

Success Response

API Response Example
{
    "success": true,
    "data": {
        "monthly_price": 5,
        "hours_purchased": 720,
        "hourly_rate": 0.0069,
        "total_cost": 5,
        "purchase_date": "2025-06-24 23:19:55",
        "expiration_date": "2025-07-24 23:19:55",
        "hours_in_month": 720,
        "time_components": {
            "whole_hours": 720,
            "minutes": 0,
            "decimal_hours": 720
        }
    },
    "timestamp": "2025-11-23 18:32:21"
}

Code Examples

Programming Languages
JavaScript (Fetch API)
async function makeRequest() {
  try {
    const response = await fetch('https://0xhost.net/API/calculate_price', {
      method: 'POST',
      headers: {
        'x-api-key': 'your_api_key_here',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
    "hours": "720",
    "monthly_price": "5.00"
})
    });
    
    const data = await response.json();
    console.log('Response:', data);
    return data;
  } catch (error) {
    console.error('Error:', error);
  }
}
Python (Requests)
import requests
import json

def make_request(api_key):
    url = 'https://0xhost.net/API/calculate_price'
    headers = {
        'x-api-key': api_key,
        'Content-Type': 'application/json'
    }
    data = {
    "hours": "720",
    "monthly_price": "5.00"
}
    
    response = requests.request('POST', url, headers=headers, json=data)
    
    if response.status_code == 200:
        return response.json()
    else:
        print(f'Error: {response.status_code}')
        return None
PHP (cURL)
function makeRequest($apiKey) {
    $url = 'https://0xhost.net/API/calculate_price';
    $data = {
    "hours": "720",
    "monthly_price": "5.00"
};
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'x-api-key: ' . $apiKey,
        'Content-Type: ' . $apiKey,
        'Content-Type: application/json'
    ]);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    return json_decode($response, true);
}
cURL Command
curl -X POST 'https://0xhost.net/API/calculate_price' \
  -H 'x-api-key: your_api_key_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "hours": "720",
    "monthly_price": "5.00"
}'