Need to calculate asset depreciation in your accounting or business application? This guide covers everything you need to know about depreciation calculation via API, including different methods, schedules, and implementation examples.
What is Depreciation?
Depreciation is the accounting method of allocating the cost of a tangible asset over its useful life. It represents how much of an asset's value has been used up. Depreciation is a non-cash expense that reduces taxable income and reflects wear and tear on assets.
Common depreciable assets include vehicles, equipment, machinery, buildings, and computers. Land is not depreciated as it doesn't wear out.
Depreciation Methods
Several methods are used to calculate depreciation:
Straight-Line Depreciation
The simplest method. Spreads cost evenly over the asset's useful life. Annual depreciation = (Cost - Salvage Value) / Useful Life.
Declining Balance
Accelerated depreciation method. Higher depreciation early, lower later. Often uses double declining balance (200% of straight-line rate).
Sum-of-Years' Digits
Another accelerated method. Uses a fraction based on remaining years over sum of all years.
Units of Production
Based on actual usage rather than time. Depreciation per unit = (Cost - Salvage) / Total Expected Units.
Using the Depreciation API
TinyFn provides a simple endpoint to calculate depreciation:
GET https://api.tinyfn.io/v1/finance/depreciation?cost=50000&salvage=5000&life=5&method=straight_line
Headers: X-API-Key: your-api-key
{
"asset_cost": 50000,
"salvage_value": 5000,
"useful_life_years": 5,
"method": "straight_line",
"annual_depreciation": 9000,
"depreciable_base": 45000,
"schedule": [
{"year": 1, "depreciation": 9000, "accumulated": 9000, "book_value": 41000},
{"year": 2, "depreciation": 9000, "accumulated": 18000, "book_value": 32000},
{"year": 3, "depreciation": 9000, "accumulated": 27000, "book_value": 23000},
{"year": 4, "depreciation": 9000, "accumulated": 36000, "book_value": 14000},
{"year": 5, "depreciation": 9000, "accumulated": 45000, "book_value": 5000}
]
}
Parameters
| Parameter | Type | Description |
|---|---|---|
cost |
number | Original cost of the asset |
salvage |
number | Estimated salvage value at end of life |
life |
integer | Useful life in years |
method |
string | Method: straight_line, declining_balance, sum_of_years, units |
rate |
number | Declining balance rate (default: 2 for double declining) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/finance/depreciation?cost=50000&salvage=5000&life=5&method=straight_line',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(`Annual depreciation: $${data.annual_depreciation}`); // Annual depreciation: $9000
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/finance/depreciation',
params={'cost': 50000, 'salvage': 5000, 'life': 5, 'method': 'straight_line'},
headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
for year in data['schedule']:
print(f"Year {year['year']}: ${year['depreciation']} depreciation, ${year['book_value']} book value")
cURL
curl "https://api.tinyfn.io/v1/finance/depreciation?cost=50000&salvage=5000&life=5&method=straight_line" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Accounting Software: Generate depreciation schedules for fixed assets
- Tax Preparation: Calculate depreciation deductions for tax returns
- Asset Management: Track book value of company assets
- Financial Planning: Project future depreciation expenses
- ERP Systems: Integrate asset depreciation into business systems
Best Practices
- Match method to asset: Use units of production for usage-based assets
- Store full schedule: Keep complete depreciation schedule for audits
- Consider tax rules: Different jurisdictions have specific requirements
- Review annually: Adjust estimates if useful life or salvage value changes
Try the Depreciation Calculator API
Get your free API key and start calculating depreciation in seconds.
Get Free API Key