Need to convert angle units in your application? This guide covers everything you need to know about angle conversion via API, including degrees, radians, gradians, and implementation examples in multiple languages.
Understanding Angle Units
An angle measures the rotation between two lines or planes. The most common units are degrees (used in everyday applications) and radians (used in mathematics and programming). Different fields use different units, making conversion essential.
A full rotation equals 360 degrees, 2π radians, or 400 gradians. Converting between these is crucial for graphics programming, navigation, physics simulations, and trigonometric calculations.
Supported Angle Units
| Unit | Code | Full Circle |
|---|---|---|
| Degree | deg | 360 |
| Radian | rad | 2π (≈6.283) |
| Gradian | grad | 400 |
| Turn/Revolution | turn | 1 |
| Arc Minute | arcmin | 21,600 |
| Arc Second | arcsec | 1,296,000 |
Using the Angle Converter API
TinyFn provides a dedicated endpoint for angle conversions:
GET https://api.tinyfn.io/v1/convert/angle
Headers: X-API-Key: your-api-key
{
"from_unit": "deg",
"to_unit": "rad",
"value": 180,
"result": 3.14159265,
"formula": "180 × (π/180)"
}
Parameters
| Parameter | Type | Description |
|---|---|---|
from |
string | Source unit code (e.g., "deg") |
to |
string | Target unit code (e.g., "rad") |
value |
number | Value to convert |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/convert/angle?from=deg&to=rad&value=180',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(data.result); // 3.14159265
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/convert/angle',
params={'from': 'deg', 'to': 'rad', 'value': 180},
headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(data['result']) # 3.14159265
cURL
curl "https://api.tinyfn.io/v1/convert/angle?from=deg&to=rad&value=180" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Graphics Programming: Convert for rotation calculations
- Game Development: Handle sprite and camera rotations
- Navigation: Convert compass bearings
- Physics Simulations: Angular velocity calculations
- CAD Software: Precise angle specifications
Best Practices
- Know your library: Most math libraries expect radians
- Use appropriate precision: Radians need more decimal places
- Normalize angles: Keep angles within expected ranges
- Document units: Always specify which unit you're using
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-convert": {
"url": "https://api.tinyfn.io/mcp/convert/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all conversion tools available via MCP in our Conversion MCP Tools for AI Agents guide.
Try the Angle Converter API
Get your free API key and start converting angles in seconds.
Get Free API Key