CyfrifiadurName

API JSON am ddim yw pob cyfrifiwr ar y safle hwn hefyd. Dim cofrestru, dim allwedd API, galluogi CORS — galwwch ef o'ch gweinydd neu'n uniongyrchol o'r porwr.

Crynodeb

Mae'r API yn rhedeg yr un math o wyddoniaeth ag y mae'r wefan yn ei ddefnyddio. Anfon gwerthoedd maes cyfrifiadur fel paramedrau ymholiad neu JSON a chael y canlyniadau cyfrifedig yn ôl fel JSON — gan gynnwys unrhyw amserlen ad-dalu neu ddata siart a gynhyrchir gan y cyfrifiadur.

  • 198+ cyfrifiaduron, pob un â'i ddiweddfa ei hun
  • Dim allwedd API — cyrchiad anhysbys, cyfyngiad cyflymder gan IP
  • CORSAccess-Control-Allow-Origin: * (defnyddiadwy ar ochr y cleient)
  • Terfyn Cyfradd: 60 ceisiadau/ awr fesul IP (HTTP 429 pan drosglwyddir)
  • Errors are free — only a successful (2xx) response uses one call from your monthly quota. Every 400, 401, 404, 429 and 500 costs you nothing.

URL Sail

https://calculator.free/api/v1/

Mynegai - rhestru pob cyfrifiannell

GET https://calculator.free/api/v1/

Dychwelyd rhestr darllenadwy gan beiriant o'r holl gyfrifiaduron gyda meysydd pob un (allwedd, label, math, rhagosodedig, uned) ac allweddi canlyniad - digon i adeiladu dibynnydd yn ddinamaidd. Each field also carries a required flag — true for the few fields that have no default (dates, mostly). Send those: a couple of calculators can infer one, the rest answer 400 without it.

Cyfrif - rhedeg cyfrifiannell

GET  https://calculator.free/api/v1/<slug>/?field=value&field=value
POST https://calculator.free/api/v1/<slug>/     (JSON or form body)

Siâp ymateb:

{
  "ok": true,
  "slug": "mortgage",
  "country": "us",
  "inputs":   { ... the values actually computed with ... },
  "results":  { ... computed result keys ... },
  "schedule": { "columns": [...], "rows": [...] } | null,
  "chart":    { "type": "pie", "slices": [...] } | null,
  "defaults_applied": ["tax", "insurance"]
}

Derbynir cyfrifiaduron sy'n ymwybodol o wledydd (morgais, benthyciad, treth incwm, treth gwerthu...) ?country=us|uk|ca|au|in|ie|nz|za. Mae' r slug anhysbys yn dychwelyd 404; mae gwlad na chynhelir neu fewnbwn gwael yn dychwelyd 400 gyda neges ddefnyddiol a' r penodiad maes.

Parameters, defaults and errors

Send only the fields you care about. Anything you leave out is filled with that field's published default — the same value the calculator page pre-fills, so the API and the website always return the same numbers for the same inputs. Each response lists what it filled in under defaults_applied.

Anything the API cannot resolve honestly is an error, never a zero: a misspelled parameter, a value of the wrong type, an unknown dropdown option, or a missing field that has no default (the date fields — a birth date cannot be guessed). Every 400 names the offending parameter and echoes the full field spec so a client can correct itself.

$ curl "https://calculator.free/api/v1/mortgage/?price=350000&rate=6.5&term=30"
{
  "ok": false,
  "error": "unknown_parameter",
  "message": "Unknown parameter 'term' for calculator 'mortgage'. Did you mean 'years'? ...",
  "unknown_parameters": ["term"],
  "did_you_mean": { "term": "years" },
  "valid_parameters": ["down", "extra", "extra_onetime", "extra_yearly", "hoa",
                       "insurance", "other", "pmi", "price", "rate", "tax", "years"],
  "fields": [ ... ]
}
errorHTTPWhen
unknown_parameter400a parameter that is not a field of this calculator (with a did-you-mean suggestion)
invalid_value400a number field that is not a number, a dropdown value outside its options, an unparseable date, or an unknown _mode
missing_parameter400the calculator produced no result because a field with no default was left empty
unsupported_country400?country= is not one this calculator has data for
bad_json400the POST body is not valid JSON
unknown_calculator404no calculator with that slug
invalid_key401an API key was sent but is unknown or inactive
rate_limited / quota_exceeded429the anonymous hourly IP limit, or a key's monthly quota, is used up
too_many_invalid_requests429too many rejected requests in one hour for this key — rejected calls are free, so they are rate-limited instead. Resets hourly; successful calls never count towards it.

The /api/v1/ index publishes every field's key, type, unit, default and whether it is required — enough to build a client that never guesses.

Dilysiant

Gallwch alw'r API heb unrhyw allwedd - mae ceisiadau di-enw wedi'u cyfyngu gan IP. I gael quota misol uwch, rhagweladwy (a defnydd masnachol), creu allwedd ar dudalen eich cyfrif a'i hanfon mewn un o dri ffordd:

GET  https://calculator.free/api/v1/mortgage/?price=350000&key=YOUR_KEY
curl -H "Authorization: Bearer YOUR_KEY" "https://calculator.free/api/v1/bmi/?units=metric&height=180&weight=80"
curl -H "X-Api-Key: YOUR_KEY"           "https://calculator.free/api/v1/bmi/?units=metric&height=180&weight=80"
  • Am ddim — di-enw (yn cyfyngu ar gyflymder IP) neu allwedd rhad ac am ddim gyda chytundeb misol bach. Dim masnachol.
  • Datblygwr &mdash; $9/mis — 10,000 o alwadau/mis, defnydd masnachol.
  • Busnes &mdash; $49/mis — 100,000 galwad/mis, trosglwyddiad blaenoriaeth.

What counts against your quota

Only a successful response does. One 2xx = one call. Every error is free: a 400 for a misspelled parameter, a bad value or a missing required field, a 404 for an unknown slug, a 401 for a bad key, a 429, and anything that goes wrong on our side. Explore the contract and fix your request as many times as you need — you are billed for answers, not for corrections.

Because errors are free they are rate-limited instead: if one key provokes more than 200 rejected responses in an hour, it gets HTTP 429 "too_many_invalid_requests" until the hour rolls over. Successful calls never count towards that, so a working integration will never see it — it only catches a client stuck in a retry loop.

Pan fydd quota misol allwedd yn cael ei ddefnyddio, mae'r API yn dychwelyd HTTP 429 gyda gwall "quota_exceeded"; mae allwedd anhysbys neu anweithredol yn dychwelyd HTTP 401. Gweld y cynlluniau llawn a chofrestru ar y Prisio tudalen.

Enghreifftiau

curl

curl "https://calculator.free/api/v1/mortgage/?price=350000&down=70000&rate=6.9&years=30"

JavaScript fetch()

const r = await fetch(
  "https://calculator.free/api/v1/bmi/?" + new URLSearchParams({
    units: "metric", height: "180", weight: "80"
  }));
const { results } = await r.json();
console.log(results.bmi, results.category);

Python

import requests

r = requests.get("https://calculator.free/api/v1/mortgage/",
                 params={"price": 350000, "down": 70000,
                         "rate": 6.9, "years": 30},
                 headers={"Authorization": "Bearer YOUR_KEY"})
print(r.json()["results"])

POST JSON

curl -X POST "https://calculator.free/api/v1/income-tax/?country=uk" \
  -H "Content-Type: application/json" \
  -d '{"income": 60000}'

Pob pwynt diwedd

Un pwynt gorffen am bob cyfrifiadur. Mae allweddi maes ac allweddi canlyniad am bob un yn y /api/v1/ mynegai.

Arian (41)
Treth a Chyfraddau Cyflog (2)
Iechyd a Ffitrwydd (28)
Math (26)
Ystadegau (15)
Trosiyddion Unedau (17)
Gwyddoniaeth a Pheirianneg (27)
Dyddiad ac Amser (15)
Bob dydd (27)

Mae'r canlyniadau yn amcangyfrifon ar gyfer cyfarwyddyd cyffredinol yn unig, nid cyngor ariannol, meddygol na thrafodion treth.