API Code Examples
Get started with code examples in JavaScript, Python, cURL, and more.
Quick Start: cURL
Test an API endpoint with a single cURL command.
curl "https://likeoptions.com/api/v1/calculate/cagr?startValue=10000&endValue=20000&years=10"
JavaScript (Fetch API)
Call the API from your browser or Node.js.
fetch('https://likeoptions.com/api/v1/calculate/mortgage', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
homePrice: 400000,
downPayment: 80000,
annualRate: 6,
years: 30
})
}).then(r => r.json()).then(data => console.log(data.result.primary));Python (requests library)
Make API calls in Python scripts or notebooks.
import requests
response = requests.post(
'https://likeoptions.com/api/v1/calculate/sip',
json={
'monthlyContribution': 500,
'annualRate': 8,
'years': 20
}
)
data = response.json()
print(f"Future Value: ${data['result']['primary']:,.2f}")Get Endpoint Documentation
Each endpoint has detailed documentation including:
- Required and optional parameters
- Request/response examples
- Error codes and handling
- Related calculators