Finance Utilities

Percentage Change

Calculate percentage change between two values with precise arithmetic. Access via MCP in Cursor, Claude Code, or other AI tools, or REST API at `/v1/finance/percentage-change`. Pass original and new values to get accurate percentage change — useful for financial analysis, performance metrics, or data comparison without floating-point errors.

API Endpoint

GET /v1/finance/percentage-change

Code Examples

curl "https://tinyfn.io/v1/finance/percentage-change" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/finance/percentage-change', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/finance/percentage-change',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's finance tools:

{
  "mcpServers": {
    "tinyfn-finance": {
      "url": "https://tinyfn.io/mcp/finance",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate percentage change between two numbers?

Pass the original value and new value as parameters. The tool returns the percentage change using the formula: ((new - original) / original) × 100.

What happens when calculating percentage change from zero?

Division by zero returns an error or infinity depending on implementation. Use a small epsilon value or handle zero baseline cases separately in your application logic.

Can MCP tools like Cursor access this for financial data analysis?

Yes, AI agents can call this tool directly through MCP to calculate stock price changes, revenue growth, or any metric comparison without manual percentage calculations.

Does this handle negative percentage changes correctly?

Yes, decreases return negative percentages. For example, going from 100 to 80 returns -20%, while 80 to 100 returns +25%.

What's the difference between percentage change and percentage difference?

Percentage change uses the original value as the denominator and shows directional change. Percentage difference typically uses the average of both values as the denominator.

Try Percentage Change Now

Get your free API key and start using Percentage Change in seconds.

Get Free API Key