# Triangle Solver API
> Triangle-solving maths as an API, computed locally and deterministically. The solve endpoint solves any triangle from three values — three sides (SSS), two sides and the included angle (SAS), two angles and a side (ASA/AAS), or the ambiguous two-sides-and-a-non-included-angle case (SSA) — using the law of cosines and the law of sines, and returns all three sides and angles, the perimeter, the Heron area and whether the triangle is acute, right or obtuse and equilateral, isosceles or scalene; for an ambiguous SSA input it also returns the second valid triangle. The right endpoint is a dedicated right-triangle solver from any two of the two legs, the hypotenuse and an acute angle, applying Pythagoras and basic trigonometry. The points endpoint builds a triangle from three cartesian vertices, giving the side lengths, the interior angles, the shoelace area and the centroid. Angles are in degrees. Everything is computed locally and deterministically, so it is instant and private. Ideal for education, CAD, surveying, game-development and engineering app developers, geometry and trigonometry tools, and STEM teaching. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This solves triangles; for areas and volumes of general shapes use a geometry API and for polygon point-set operations a polygon API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/triangle-api/..."
```

## Pricing
- **Free** (Free) — 3,000 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 40,000 calls/Mo, 5 req/s
- **Pro** ($15/Mo) — 300,000 calls/Mo, 15 req/s
- **Mega** ($49/Mo) — 2,009,000 calls/Mo, 40 req/s

## Endpoints

### Triangle

#### `GET /v1/points` — Triangle from points

**Parameters:**
- `ax` (query, required, string) — Ax Example: `0`
- `ay` (query, required, string) — Ay Example: `0`
- `bx` (query, required, string) — Bx Example: `4`
- `by` (query, required, string) — By Example: `0`
- `cx` (query, required, string) — Cx Example: `0`
- `cy` (query, required, string) — Cy Example: `3`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/triangle-api/v1/points?ax=0&ay=0&bx=4&by=0&cx=0&cy=3"
```

**Response:**
```json
{
    "data": {
        "area": 6,
        "note": "Side a = |BC|, b = |CA|, c = |AB|. Area by the shoelace formula; centroid is the average of the vertices.",
        "inputs": {
            "A": [
                0,
                0
            ],
            "B": [
                4,
                0
            ],
            "C": [
                0,
                3
            ]
        },
        "side_a": 5,
        "side_b": 3,
        "side_c": 4,
        "centroid": [
            1.333333,
            1
        ],
        "perimeter": 12,
        "side_type": "scalene",
        "angle_type": "right",
        "angle_A_deg": 90,
        "angle_B_deg": 36.869898,
        "angle_C_deg": 53.130102
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:07.071Z",
        "request_id": "432f669a-2777-4c65-a6e6-4f09543db665"
    },
    "status": "ok",
    "message": "From points",
    "success": true
}
```

#### `GET /v1/right` — Right triangle

**Parameters:**
- `leg_a` (query, optional, string) — Leg a Example: `3`
- `leg_b` (query, optional, string) — Leg b Example: `4`
- `hypotenuse` (query, optional, string) — Hypotenuse
- `angle` (query, optional, string) — An acute angle (deg)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/triangle-api/v1/right?leg_a=3&leg_b=4"
```

**Response:**
```json
{
    "data": {
        "area": 6,
        "note": "Right triangle: c² = a² + b² (Pythagoras); angle A = asin(a/c), opposite leg a.",
        "leg_a": 3,
        "leg_b": 4,
        "perimeter": 12,
        "hypotenuse": 5,
        "angle_A_deg": 36.869898,
        "angle_B_deg": 53.130102,
        "angle_C_deg": 90
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:07.177Z",
        "request_id": "394f97e2-f442-4369-8f54-6f6567b8d07b"
    },
    "status": "ok",
    "message": "Right triangle",
    "success": true
}
```

#### `GET /v1/solve` — Solve a triangle

**Parameters:**
- `side_a` (query, optional, string) — Side a (opposite angle A) Example: `3`
- `side_b` (query, optional, string) — Side b Example: `4`
- `side_c` (query, optional, string) — Side c Example: `5`
- `angle_A` (query, optional, string) — Angle A (deg)
- `angle_B` (query, optional, string) — Angle B (deg)
- `angle_C` (query, optional, string) — Angle C (deg)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/triangle-api/v1/solve?side_a=3&side_b=4&side_c=5"
```

**Response:**
```json
{
    "data": {
        "area": 6,
        "method": "SSS",
        "side_a": 3,
        "side_b": 4,
        "side_c": 5,
        "perimeter": 12,
        "side_type": "scalene",
        "angle_type": "right",
        "angle_A_deg": 36.869898,
        "angle_B_deg": 53.130102,
        "angle_C_deg": 90
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:07.284Z",
        "request_id": "0980a284-83e9-47c1-8678-5000a931d492"
    },
    "status": "ok",
    "message": "Solve triangle",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/triangle-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "notes": "Angles in degrees; side a is opposite angle A. SSA can be ambiguous — a second_solution is returned when one exists.",
        "service": "triangle-api",
        "formulae": {
            "shoelace": "½|ax(by−cy)+bx(cy−ay)+cx(ay−by)|",
            "heron_area": "√(s(s−a)(s−b)(s−c)), s = (a+b+c)/2",
            "law_of_sines": "a/sinA = b/sinB = c/sinC",
            "law_of_cosines": "a² = b² + c² − 2bc·cosA"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/right": "Right-triangle solver from any two of leg_a, leg_b, hypotenuse, angle.",
            "GET /v1/solve": "Solve a triangle from three values (SSS, SAS, ASA, AAS or SSA).",
            "GET /v1/points": "Sides, angles, area and centroid from three vertices."
        },
        "description": "Triangle solver: solve any triangle from SSS, SAS, ASA, AAS or the ambiguous SSA case; a dedicated right-triangle solver; and a triangle from three cartesian points."
    },
    "meta": {
        "timestamp": "2026-06-04T18:38:07.392Z",
        "request_id": "a516dc07-849d-45eb-9f77-e461fcb4eab2"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/triangle-api
OpenAPI spec: https://www.oanor.com/api/triangle-api/openapi.json
