Angle Converter API: The Complete Guide

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
Degreedeg360
Radianrad2π (≈6.283)
Gradiangrad400
Turn/Revolutionturn1
Arc Minutearcmin21,600
Arc Secondarcsec1,296,000
Common Conversions: 180° = π rad, 90° = π/2 rad, 1 rad ≈ 57.2958°

Using the Angle Converter API

TinyFn provides a dedicated endpoint for angle conversions:

API Request
GET https://api.tinyfn.io/v1/convert/angle
Headers: X-API-Key: your-api-key
Response
{
  "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

  1. Know your library: Most math libraries expect radians
  2. Use appropriate precision: Radians need more decimal places
  3. Normalize angles: Keep angles within expected ranges
  4. 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

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key