API contract
Preview, insertion confirmation and periodic table endpoints.
Authentication and Origin
Send X-Formulix-Chave on every /v1/* route. The key must be active and the Origin hostname must match the account’s domains, including subdomains. The browser supplies Origin: do not try to set it manually in JavaScript. Requests without a valid origin are rejected.
The OPTIONS preflight accepts origins registered to an account or development origins, GET/POST methods and Content-Type/X-Formulix-Chave headers. The actual request still checks the domains belonging to the key’s account. Responses use Vary: Origin and Cache-Control: no-store. The permitted origin is reflected without a wildcard. A rejected origin may appear only as a browser CORS error.
This is a public key, not an administrator credential; Origin can be forged outside browsers. Revocations and domain changes are reloaded in about 5 seconds by default.
POST /v1/calc — preview
JSON body: { op, dados, idioma, notacao }. op selects the operation; dados contains its parameters. The default language is en; notacao is optional. For English, defaults include decimal points and long division; an explicit notation override can use { "decimal": "." }. Responses depend on the operation: HTML, LaTeX, SVG or auxiliary JSON data. A successful preview records one preview and zero insertions.
const response = await fetch('https://api.formulix.example/v1/calc', { // PLACEHOLDER URL
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Formulix-Chave': 'YOUR_PUBLIC_KEY' // PLACEHOLDER
},
body: JSON.stringify({
op: 'word', dados: { html: '<p>Text without equations</p>' },
idioma: 'en'
})
});
const result = await response.json();
if (!response.ok) throw new Error(result.erro);
// This example returns: { eqs: [] }Recognized operations: divisao, multiplicacao, adicao, subtracao, ruffini, mmc, fatoracao, fracoes, regra3, eq1, eq2, sistema, tabela, estudo, grafico, qeq, qmassa, qdist, qvid, qtit, qpaul, qorg, qcad, qtab, word. Fields in dados vary by operation; use the adapter to construct requests. There is no single parameter schema. These identifiers are part of the API contract and are not translated.
POST /v1/inserir — final output
The body includes tipo, type-specific data below and optional idioma and notacao. Responses are JSON without a common envelope.
| tipo | Type-specific input | Output and usage |
|---|---|---|
| formula | latex; optional bloco | { html } with MathML; 1 insertion. Nonempty LaTeX, up to 20,000 characters. |
| word | html; optional rtf | { html }; 1 per converted equation (zero when there are none). |
| grafico | Graph operation data | { svg, w, h, funcoes, alt }; 1 insertion. |
| conta / quimica | op and dados; recognized op except grafico/word | { html }, { bloco: true, html } or { svg, w, h, alt }, depending on operation; 1 insertion. |
// Formula body; use the same headers as for a preview.
{
"tipo": "formula",
"latex": "x^2",
"bloco": false,
"idioma": "en"
}
// 200 response: { "html": "<math ...>...</math>" }The client converts SVG to PNG and uploads through the platform. The calculation API does not store images. Every accepted confirmation counts, including edits; there is no identifier-based idempotency. Avoid automatically retrying a confirmation if you cannot tell whether the first request was accepted.
GET /v1/tabela?idioma=en
Returns an array of elements { z, s, nome, pos, cor } for the periodic table grid. A valid key and Origin are required even though the data is public. It records neither insertion nor preview; the per-minute limit applies. The default language is English.
Limits
- Body: up to 15 MiB. Larger requests may have their connection closed after a 413 response.
- Burst: 1,200 requests per key per minute, per process, including previews and table requests. This ceiling is not global across multiple processes.
- Plan: 500 / 5,000 / 25,000 insertions, or Network with no numerical ceiling. Free limits both account and domain; paid plans total the account.
- Development: separate default limit of 300 insertions/month/account, configurable with
FORMULIX_DEV_LIMITE. Covers localhost, .localhost subdomains, 127.0.0.1, [::1] and .test domains. A valid key is still required. - Usage synchronizes between processes every 5 seconds by default, rather than using a global per-request transactional counter. The month follows UTC.
Errors
Application errors use JSON { "erro": "message" }. Calculation validation messages may be localized; the erro field name does not change.
| HTTP | Meaning |
|---|---|
| 400 | Invalid JSON. — invalid JSON or a non-object body. |
| 401 | Invalid key. — missing, invalid or revoked key. |
| 402 | Monthly insertion limit reached. — plan or development ceiling. |
| 403 | Origin not allowed for this key. — domain rejected; rejected preflight may have no body. |
| 404 | Unknown route. or Unknown operation. |
| 413 | Request too large. — body exceeds limit. |
| 422 | Invalid input; message in erro. |
| 429 | Rate limit reached. — too many requests per minute. |
| 500 | Internal error. — internal failure. |
/saude returns { "ok": true } without authentication; it does not confirm that a key has access to the service.