VolumeCalculator.site

Calculate volumes with ease

Volume Calculator API

Integrate our volume calculation capabilities directly into your applications with our simple REST API.

API Overview

Our Volume Calculator API provides programmatic access to all the calculation capabilities available on our website. The API follows RESTful principles and returns JSON responses.

Base URL

https://api.volumecalculator.site/v1/

Authentication

All API requests require an API key sent in the X-API-Key header. You can obtain an API key by contacting us at contact@volumecalculator.site.

Rate Limits

  • Free tier: 100 requests per day
  • Basic tier: 1,000 requests per day
  • Professional tier: 10,000 requests per day
  • Enterprise: Custom limits available

Response Codes

Code Description
200 Success
400 Bad request (invalid parameters)
401 Unauthorized (invalid API key)
429 Too many requests
500 Server error

API Endpoints

1. Cube Volume

Calculate the volume of a cube given its side length.

Request
POST /cube
Content-Type: application/json
X-API-Key: your_api_key_here

{
  "side": 5,
  "unit": "cm"
}
Response
{
  "success": true,
  "shape": "cube",
  "volume": 125,
  "unit": "cm³",
  "formula": "V = s³ = 5³",
  "calculation": "5 × 5 × 5 = 125"
}

2. Sphere Volume

Calculate the volume of a sphere given its radius.

Request
POST /sphere
Content-Type: application/json
X-API-Key: your_api_key_here

{
  "radius": 7,
  "unit": "cm"
}
Response
{
  "success": true,
  "shape": "sphere",
  "volume": 1436.76,
  "unit": "cm³",
  "formula": "V = (4/3)πr³ = (4/3) × π × 7³",
  "calculation": "(4/3) × 3.14159 × 343 ≈ 1436.76"
}

3. Cylinder Volume

Calculate the volume of a cylinder given its radius and height.

Request
POST /cylinder
Content-Type: application/json
X-API-Key: your_api_key_here

{
  "radius": 3,
  "height": 8,
  "unit": "cm"
}
Response
{
  "success": true,
  "shape": "cylinder",
  "volume": 226.19,
  "unit": "cm³",
  "formula": "V = πr²h = π × 3² × 8",
  "calculation": "3.14159 × 9 × 8 ≈ 226.19"
}

4. Cone Volume

Calculate the volume of a cone given its radius and height.

Request
POST /cone
Content-Type: application/json
X-API-Key: your_api_key_here

{
  "radius": 4,
  "height": 9,
  "unit": "cm"
}
Response
{
  "success": true,
  "shape": "cone",
  "volume": 150.8,
  "unit": "cm³",
  "formula": "V = (1/3)πr²h = (1/3) × π × 4² × 9",
  "calculation": "(1/3) × 3.14159 × 16 × 9 ≈ 150.8"
}

5. Pyramid Volume

Calculate the volume of a pyramid given its base dimensions and height.

Request
POST /pyramid
Content-Type: application/json
X-API-Key: your_api_key_here

{
  "base_length": 6,
  "base_width": 6,
  "height": 10,
  "unit": "cm"
}
Response
{
  "success": true,
  "shape": "pyramid",
  "volume": 120,
  "unit": "cm³",
  "formula": "V = (1/3) × base_area × height = (1/3) × (6 × 6) × 10",
  "calculation": "(1/3) × 36 × 10 = 120"
}

6. Rectangular Prism Volume

Calculate the volume of a rectangular prism given its length, width, and height.

Request
POST /prism
Content-Type: application/json
X-API-Key: your_api_key_here

{
  "length": 10,
  "width": 5,
  "height": 2,
  "unit": "cm"
}
Response
{
  "success": true,
  "shape": "rectangular_prism",
  "volume": 100,
  "unit": "cm³",
  "formula": "V = l × w × h = 10 × 5 × 2",
  "calculation": "10 × 5 × 2 = 100"
}

API Usage Examples

JavaScript Example

async function calculateCubeVolume(side) {
  const response = await fetch('https://api.volumecalculator.site/v1/cube', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-API-Key': 'your_api_key_here'
    },
    body: JSON.stringify({
      side: side,
      unit: 'cm'
    })
  });
  
  const data = await response.json();
  return data;
}

// Usage
calculateCubeVolume(5).then(result => {
  console.log('Volume:', result.volume, result.unit);
});

Python Example

import requests

def calculate_sphere_volume(radius):
    url = "https://api.volumecalculator.site/v1/sphere"
    headers = {
        "Content-Type": "application/json",
        "X-API-Key": "your_api_key_here"
    }
    data = {
        "radius": radius,
        "unit": "cm"
    }
    
    response = requests.post(url, json=data, headers=headers)
    return response.json()

# Usage
result = calculate_sphere_volume(7)
print(f"Volume: {result['volume']} {result['unit']}")

PHP Example

function calculateCylinderVolume($radius, $height) {
    $url = 'https://api.volumecalculator.site/v1/cylinder';
    $data = [
        'radius' => $radius,
        'height' => $height,
        'unit' => 'cm'
    ];
    
    $options = [
        'http' => [
            'header' => "Content-Type: application/json\r\n" .
                        "X-API-Key: your_api_key_here\r\n",
            'method' => 'POST',
            'content' => json_encode($data)
        ]
    ];
    
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    return json_decode($result, true);
}

// Usage
$volume = calculateCylinderVolume(3, 8);
echo "Volume: " . $volume['volume'] . " " . $volume['unit'];