# Truth Table API
> Evaluate boolean-logic expressions and generate complete truth tables. The table endpoint takes a boolean expression, finds its variables, builds every row of the truth table (the first variable is the most-significant bit, the standard convention), and returns each row's values and result, the list of minterms (the row indices where the expression is true), a classification of tautology / contradiction / contingency, and a canonical sum-of-products (SOP) form. The evaluate endpoint computes the expression's value for one specific assignment of its variables. It understands the full set of operators in both symbol and word form — NOT (!, ~, ¬), AND (&, &&, ∧, *, ., AND), OR (|, ||, ∨, +, OR), XOR (^, ⊕), NAND, NOR, XNOR, implication (->, =>, →, IMPLIES) and the biconditional (<->, <=>, ↔, IFF) — with the usual precedence (NOT > AND > XOR > OR > IMPLIES > IFF), parentheses, and the constants 0/1 and true/false. Everything is computed locally and deterministically, so it is instant and private. Ideal for digital-logic and discrete-math teaching, hardware and HDL design, simplifying conditions in code, SAT-style sanity checks, and interview prep. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This evaluates boolean logic and builds truth tables; for arithmetic and equations use a math 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/truthtable-api/..."
```

## Pricing
- **Free** (Free) — 5,635 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 15,150 calls/Mo, 8 req/s
- **Pro** ($27/Mo) — 202,500 calls/Mo, 20 req/s
- **Mega** ($65/Mo) — 1,055,000 calls/Mo, 50 req/s

## Endpoints

### Logic

#### `GET /v1/evaluate` — Evaluate under an assignment

**Parameters:**
- `expression` (query, required, string) — The boolean expression Example: `P -> Q`
- `assign` (query, optional, string) — Assignment, e.g. P=1,Q=0 Example: `P=1,Q=0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/truthtable-api/v1/evaluate?expression=P+-%3E+Q&assign=P%3D1%2CQ%3D0"
```

**Response:**
```json
{
    "data": {
        "result": 0,
        "boolean": false,
        "variables": [
            "P",
            "Q"
        ],
        "assignment": {
            "P": 1,
            "Q": 0
        },
        "expression": "P -> Q"
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:16.804Z",
        "request_id": "6717889c-64f4-4564-973a-0fb905d0c791"
    },
    "status": "ok",
    "message": "Evaluate",
    "success": true
}
```

#### `GET /v1/table` — Build a full truth table

**Parameters:**
- `expression` (query, required, string) — The boolean expression Example: `A AND (B OR !C)`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/truthtable-api/v1/table?expression=A+AND+%28B+OR+%21C%29"
```

**Response:**
```json
{
    "data": {
        "rows": [
            {
                "index": 0,
                "result": 0,
                "values": {
                    "A": 0,
                    "B": 0,
                    "C": 0
                }
            },
            {
                "index": 1,
                "result": 0,
                "values": {
                    "A": 0,
                    "B": 0,
                    "C": 1
                }
            },
            {
                "index": 2,
                "result": 0,
                "values": {
                    "A": 0,
                    "B": 1,
                    "C": 0
                }
            },
            {
                "index": 3,
                "result": 0,
                "values": {
                    "A": 0,
                    "B": 1,
                    "C": 1
                }
            },
            {
                "index": 4,
                "result": 1,
                "values": {
                    "A": 1,
                    "B": 0,
                    "C": 0
                }
            },
            {
                "index": 5,
                "result": 0,
                "values": {
                    "A": 1,
                    "B": 0,
                    "C": 1
                }
            },
            {
                "index": 6,
                "result": 1,
                "values": {
                    "A": 1,
                    "B": 1,
                    "
…(truncated, see openapi.json for full schema)
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Truth Table API",
        "notes": "Up to 12 variables (4096 rows) for the table. Precedence: NOT > AND > XOR > OR > IMPLIES > IFF; IMPLIES is right-associative. NOT is prefix only. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/table",
                "params": {
                    "expression": "the boolean expression, e.g. A AND (B OR !C)"
                },
                "returns": "variables, every row, minterms, classification and canonical SOP"
            },
            {
                "path": "/v1/evaluate",
                "params": {
                    "assign": "the assignment, e.g. A=1,B=0,C=1",
                    "expression": "the boolean expression"
                },
                "returns": "the boolean result for that assignment"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "operators": {
            "or": "| || ∨ + OR",
            "and": "& && ∧ * . AND",
            "not": "! ~ ¬ NOT",
            "xor": "^ ⊕ XOR",
            "other": "NAND NOR XNOR, -> => → IMPLIES, <-> <=> ↔ IFF",
            "constants": "0 1 true false"
        },
        "description": "Evaluate boolean-logic expressions and generate complete truth tables. The table endpoint takes a boolean expression, finds its variables, builds every row of
…(truncated, see openapi.json for full schema)
```


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