API Documentation

Integrate interpolation calculations into your applications with our RESTful API. Support for both linear interpolation and polynomial interpolation methods.

Getting Started

Our API provides programmatic access to interpolation calculations. All endpoints return JSON responses and support CORS for client-side applications.

Base URL

https://interpolationcalc.com/api/v1

Authentication

No authentication required for basic usage. Rate limiting applies: 100 requests per minute per IP address.

Interpolation Endpoint

GET /interpolate

Parameters

Parameter Type Required Description
method string Yes Interpolation method: linear or polynomial
points string Yes Data points in format: x1,y1;x2,y2;x3,y3
x number Yes X value to interpolate

Example Request

GET /api/v1/interpolate?method=linear&points=1,2;3,8;5,18&x=4

Example Response

{
  "success": true,
  "method": "linear",
  "x": 4,
  "result": 13,
  "equation": "y = 8 + ((18 - 8) / (5 - 3)) × (4 - 3)",
  "points_used": [
    {"x": 3, "y": 8},
    {"x": 5, "y": 18}
  ],
  "metadata": {
    "calculation_time_ms": 0.5,
    "interpolation_type": "interpolation"
  }
}

Error Responses

The API returns appropriate HTTP status codes and error messages:

400 Bad Request

{
  "success": false,
  "error": "Invalid method. Use 'linear' or 'polynomial'",
  "code": "INVALID_METHOD"
}

422 Unprocessable Entity

{
  "success": false,
  "error": "Insufficient data points. Minimum 2 points required",
  "code": "INSUFFICIENT_DATA"
}

429 Too Many Requests

{
  "success": false,
  "error": "Rate limit exceeded. Maximum 100 requests per minute",
  "code": "RATE_LIMIT_EXCEEDED"
}

Code Examples

JavaScript (Fetch API)

const interpolate = async (method, points, x) => {
  const params = new URLSearchParams({
    method: method,
    points: points.map(p => `${p.x},${p.y}`).join(';'),
    x: x
  });
  
  const response = await fetch(`https://interpolationcalc.com/api/v1/interpolate?${params}`);
  const data = await response.json();
  
  if (data.success) {
    console.log(`Result: ${data.result}`);
    return data.result;
  } else {
    throw new Error(data.error);
  }
};

// Usage
interpolate('linear', [{x: 1, y: 2}, {x: 3, y: 8}], 2)
  .then(result => console.log(result))
  .catch(error => console.error(error));

Python (requests)

import requests

def interpolate(method, points, x):
    points_str = ';'.join([f"{p['x']},{p['y']}" for p in points])
    
    params = {
        'method': method,
        'points': points_str,
        'x': x
    }
    
    response = requests.get('https://interpolationcalc.com/api/v1/interpolate', params=params)
    data = response.json()
    
    if data['success']:
        return data['result']
    else:
        raise Exception(data['error'])

# Usage
points = [{'x': 1, 'y': 2}, {'x': 3, 'y': 8}]
result = interpolate('linear', points, 2)
print(f"Result: {result}")

cURL

curl -X GET "https://interpolationcalc.com/api/v1/interpolate?method=linear&points=1,2;3,8&x=2" \
     -H "Accept: application/json"

Embed Widget

Embed our calculator directly into your website with a simple iframe:

Basic Embed

<iframe 
  src="https://interpolationcalc.com/calculator?embed=true" 
  width="100%" 
  height="600"
  frameborder="0"
  title="Interpolation Calculator">
</iframe>

Pre-filled Embed

<iframe 
  src="https://interpolationcalc.com/calculator?embed=true&method=linear&points=1,2;3,8&x=2" 
  width="100%" 
  height="600"
  frameborder="0"
  title="Interpolation Calculator">
</iframe>

Preview

Rate Limits & Usage

Rate Limits

  • Free Tier: 100 requests per minute per IP
  • Burst Limit: 10 requests per second
  • Daily Limit: 10,000 requests per day

Response Headers

Rate limit information is included in response headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1643723400

Best Practices

  • Cache results when possible to reduce API calls
  • Implement exponential backoff for rate limit errors
  • Validate input data before making API calls
  • Use appropriate error handling for network issues

Support

Need help with the API? We're here to assist:

📧 Email Support

Technical questions and integration help

api@interpolationcalc.com

📚 Documentation

Comprehensive guides and examples

View Examples

🐛 Bug Reports

Report issues or request features

Contact Us