Formulix documentation← Back to the site
Reference / Formulix 0.1.0

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.

tipoType-specific inputOutput and usage
formulalatex; optional bloco{ html } with MathML; 1 insertion. Nonempty LaTeX, up to 20,000 characters.
wordhtml; optional rtf{ html }; 1 per converted equation (zero when there are none).
graficoGraph operation data{ svg, w, h, funcoes, alt }; 1 insertion.
conta / quimicaop 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

Errors

Application errors use JSON { "erro": "message" }. Calculation validation messages may be localized; the erro field name does not change.

HTTPMeaning
400Invalid JSON. — invalid JSON or a non-object body.
401Invalid key. — missing, invalid or revoked key.
402Monthly insertion limit reached. — plan or development ceiling.
403Origin not allowed for this key. — domain rejected; rejected preflight may have no body.
404Unknown route. or Unknown operation.
413Request too large. — body exceeds limit.
422Invalid input; message in erro.
429Rate limit reached. — too many requests per minute.
500Internal error. — internal failure.

/saude returns { "ok": true } without authentication; it does not confirm that a key has access to the service.