Need to calculate tips in your application? This guide covers everything you need to know about tip calculations via API, including tip percentages, bill splitting, and implementation examples in multiple languages.
What is a Tip Calculator?
A tip calculator helps determine the appropriate gratuity amount based on the bill total and desired tip percentage. It can also split the bill among multiple people, making it easier to handle group dining situations.
Tip calculators are essential for restaurant apps, expense tracking tools, and personal finance applications.
Standard Tip Percentages
Common tip percentages in the United States:
| Service Level | Tip Percentage |
|---|---|
| Poor service | 10-15% |
| Average service | 15-18% |
| Good service | 18-20% |
| Excellent service | 20-25%+ |
Using the Tip Calculator API
TinyFn provides a simple endpoint for tip calculations:
GET https://api.tinyfn.io/v1/math/tip
Headers: X-API-Key: your-api-key
{
"bill_amount": 85.50,
"tip_percentage": 20,
"tip_amount": 17.10,
"total": 102.60,
"split_count": 4,
"per_person": 25.65
}
Parameters
| Parameter | Type | Description |
|---|---|---|
bill_amount |
number | Total bill amount before tip |
tip_percentage |
number | Tip percentage (e.g., 20 for 20%) |
split_count |
integer | Number of people to split bill (default: 1) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/math/tip?bill_amount=85.50&tip_percentage=20&split_count=4',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(data.tip_amount); // 17.10
console.log(data.per_person); // 25.65
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/math/tip',
params={
'bill_amount': 85.50,
'tip_percentage': 20,
'split_count': 4
},
headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(data['per_person']) # 25.65
cURL
curl "https://api.tinyfn.io/v1/math/tip?bill_amount=85.50&tip_percentage=20&split_count=4" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Restaurant Apps: Calculate tips at checkout
- Expense Tracking: Log meal expenses with tips
- Bill Splitting Apps: Divide costs among groups
- Point of Sale Systems: Suggest tip amounts
- Travel Apps: Help tourists with local tipping customs
Best Practices
- Offer presets: Provide common tip percentages (15%, 18%, 20%, 25%)
- Round options: Offer to round up to nearest dollar
- Show breakdown: Display tip amount, total, and per-person clearly
- Consider locale: Adjust defaults based on user's region
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-math": {
"url": "https://api.tinyfn.io/mcp/math/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all math tools available via MCP in our Math MCP Tools for AI Agents guide.
Try the Tip Calculator API
Get your free API key and start calculating tips in seconds.
Get Free API Key