Overview
`roman1` and `roman2` are uppercased and then validated against the canonical pattern for numerals from I to MMMCMXCIX: no symbol repeated more than three times in a row and only the six standard subtractive pairs (IV, IX, XL, XC, CD, CM). Forms such as IIII, IC or VV fail with a 400 that names the bad numeral, so both operands are always between 1 and 3999. Each is converted to an integer by a left-to-right scan that subtracts a smaller symbol placed before a larger one.
`operation` is one of `add` (the default), `subtract`, `multiply` or `divide`, case-insensitive. Division is integer division rounded down and the remainder is discarded, so XX divided by III returns VI. The integer result is then converted back greedily from the largest value down.
Roman numerals have no zero, no negatives and, in standard form, nothing above 3999. A subtraction that comes to zero or less, or a product or sum above 3999, returns a 400 with a message explaining which limit was hit, rather than a partial result.
On success, `result_number` and `result_roman` hold the answer. `equation_numeric` and `equation_roman` write out the whole calculation with the operators +, -, × and ÷, using the numerals as you sent them after uppercasing. `roman1_value` and `roman2_value` are the parsed operands, which is a convenient way to show a learner what each numeral means.
Live Test Roman Numeral Math API →
Endpoint
One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.
curl "https://api.apiverve.com/v1/romannumeralmath?roman1=XIV&roman2=VI&operation=add" \
-H "x-api-key: your_api_key_here"const res = await fetch('https://api.apiverve.com/v1/romannumeralmath?roman1=XIV&roman2=VI&operation=add', {
headers: { 'x-api-key': 'your_api_key_here' },
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const { data } = await res.json();
console.log(data);import requests
res = requests.get(
"https://api.apiverve.com/v1/romannumeralmath?roman1=XIV&roman2=VI&operation=add",
headers={"x-api-key": "your_api_key_here"},
timeout=15,
)
res.raise_for_status()
print(res.json()["data"])package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.apiverve.com/v1/romannumeralmath?roman1=XIV&roman2=VI&operation=add", nil)
req.Header.Set("x-api-key", "your_api_key_here")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.
Authentication
Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.
A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.
Parameters
Sent in the query string. Premium parameters are accepted on every plan but only take effect on plans that include them.
| Parameter | Type | Description |
|---|---|---|
roman1Required | string | The first Roman numeral |
roman2Required | string | The second Roman numeral |
operationOptional | string | Operation to performaddsubtractmultiplydividedefault add |
Response
Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.
{
"status": "ok",
"error": null,
"data": {
"roman1": "XIV",
"roman2": "VI",
"roman1_value": 14,
"roman2_value": 6,
"operation": "add",
"result_number": 20,
"result_roman": "XX",
"equation_numeric": "14 + 6 = 20",
"equation_roman": "XIV + VI = XX"
}
}
Response fields
Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.
| Field | Type | Example | Description |
|---|---|---|---|
roman1 | string | "XIV" | First operand as it was supplied, in Roman numerals |
roman2 | string | "VI" | Second operand as it was supplied, in Roman numerals |
roman1_value | number | 14 | First operand converted to a number |
roman2_value | number | 6 | Second operand converted to a number |
operation | string | "add" | The arithmetic operation that was applied |
result_number | number | 20 | Result of the operation as a number |
result_roman | string | "XX" | Result of the operation in Roman numerals |
equation_numeric | string | "14 + 6 = 20" | Mathematical equation in numeric format |
equation_roman | string | "XIV + VI = XX" | Mathematical equation in Roman numeral format |
Errors
Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.
| Status | Meaning | What to do |
|---|---|---|
400 | Input was rejected | Read error; it names the parameter. |
401 | Key missing or invalid | Check the header name and the key value. |
403 | Key valid, but not permitted | A key restriction or IP allow-list; see key scoping. |
429 | Rate limited, or out of credits | Read error to tell them apart; see rate limits. |
Use cases
- Educational Tools
- Teach Roman numeral arithmetic and ancient mathematics in interactive learning applications
- Historical Calculators
- Create calculators for historical contexts requiring Roman numeral operations
- Puzzle Games
- Build mathematical puzzles and games using Roman numeral arithmetic
- Format Conversion
- Perform calculations while maintaining Roman numeral formatting for specialized applications
Other ways to use Roman Numeral Math
Set up Roman Numeral Math on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them — one key, one balance.
Related
More in Math/Calculations: