Need to calculate markup in your application? This guide covers everything you need to know about markup calculations via API, including the formula, pricing strategies, and implementation examples in multiple languages.
What is Markup?
Markup is the percentage added to the cost of a product to arrive at the selling price. It's calculated as (Selling Price - Cost) / Cost, expressed as a percentage.
Markup is a fundamental concept in retail and wholesale pricing. Understanding markup helps businesses set profitable prices while remaining competitive.
Markup Percentage = ((Selling Price - Cost) / Cost) × 100
Selling Price = Cost × (1 + Markup Percentage / 100)
Markup vs Margin
Markup and margin are often confused but are different calculations:
| Metric | Formula | Base |
|---|---|---|
| Markup | (Price - Cost) / Cost | Cost |
| Margin | (Price - Cost) / Price | Selling Price |
Using the Markup Calculator API
TinyFn provides a simple endpoint for markup calculations:
GET https://api.tinyfn.io/v1/math/markup
Headers: X-API-Key: your-api-key
{
"cost": 60,
"markup_percentage": 50,
"selling_price": 90,
"profit": 30,
"margin_percentage": 33.33
}
Parameters
| Parameter | Type | Description |
|---|---|---|
cost |
number | Cost of the product |
markup_percentage |
number | Desired markup percentage |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/math/markup?cost=60&markup_percentage=50',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(data.selling_price); // 90
console.log(data.profit); // 30
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/math/markup',
params={'cost': 60, 'markup_percentage': 50},
headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(data['selling_price']) # 90
cURL
curl "https://api.tinyfn.io/v1/math/markup?cost=60&markup_percentage=50" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Retail Pricing: Calculate selling prices from cost
- Wholesale: Apply consistent markup across products
- Cost-Plus Contracts: Calculate prices with agreed markup
- Inventory Management: Set prices for new inventory
- Price Quotes: Generate quotes with markup built in
Best Practices
- Know your costs: Include all costs for accurate markup
- Research competitors: Ensure markup keeps prices competitive
- Consider elasticity: Higher markup may reduce volume
- Vary by category: Different products may need different markups
Try the Markup Calculator API
Get your free API key and start calculating markup in seconds.
Get Free API Key