Unit Conversion

Unit Conversion

Math & Calculations Credits / request: 1

Converts length, mass, volume, temperature, area, speed and data units.

GET https://api.apikodu.com/api/v1/math/unitconvert
Documentation
Overview

Converts units (length, mass, volume, temperature, area, speed, pressure, data). Agriculture units: da, donum, ha, kental, hl.

Authentication

Every request requires the x-api-key header. Credits used and remaining quota are returned in response headers (x-api-credits-used, x-api-remaining-credits, x-rate-limit-*).

Request
GET https://api.apikodu.com/api/v1/math/unitconvert?value=10&from=da&to=ha&category=area
Query string.
Parameters
Name Type Required Default Options Description
value number * Required — — Number.
from string * Required — — Source unit. Valid values are in the category rows below.
to string * Required — — Target unit. Valid values are in the category rows below.
category string Optional — length mass volume temperature area speed pressure data Inferred from units if empty.
from / to — length unit Optional — m km cm mm mi yd ft in Length units.
from / to — mass unit Optional — kg g mg t q lb oz Mass units (q = quintal).
from / to — volume unit Optional — l ml m3 hl gal bu Volume units.
from / to — area unit Optional — m2 km2 ha a da donum acre ft2 Area units (a = are, da = decare).
from / to — speed unit Optional — mps kmh mph knot Speed units.
from / to — pressure unit Optional — pa hpa kpa bar psi Pressure units.
from / to — data unit Optional — b kb mb gb tb kib mib gib Data units.
from / to — temperature unit Optional — c f k Temperature units.
Response
Name Type Description
value number Number in the target unit. Non-temperature categories use a factor.
from string Normalized source unit (e.g. da, km, c).
to string Normalized target unit.
category string length, mass, volume, temperature, area, speed, pressure or data.
Errors
HTTP code Description
400 -241 value is missing or not a number.
400 -245 from, to or category is invalid / mismatched (different categories).
401 -100 x-api-key is missing, empty, malformed, inactive, banned, expired, IP-restricted, or not allowed for this API.
429 -221 Per-minute request limit exceeded. Response headers: x-rate-limit-limit, x-rate-limit-remaining, x-rate-limit-reset.
429 — Package credit quota cannot cover this request. Body may be { error, limit, currentUsage, requestCost } (no code field).
500 -1 Unexpected server error. message is a generic error text without technical details.
Notes
  • Success body is { data: { ... } }. Error body is { code, message }. code is an ApiResponseCode enum value (negative integer).

Sample response

{
  "data": {
    "value": 10000.0,
    "from": "km",
    "to": "m",
    "category": "length"
  }
}

Code samples

  
      const response = await fetch('https://api.apikodu.com/api/v1/math/unitconvert', {
        method: 'GET',
        headers: {
          'x-api-key': 'YOUR_API_KEY'
        }
      });

      const data = await response.json();
      console.log(data);
  
  
      import requests

      headers = {
          'x-api-key': 'YOUR_API_KEY'
      }

      response = requests.get('https://api.apikodu.com/api/v1/math/unitconvert', headers=headers)
      print(response.json())
  
  
      using var client = new HttpClient();
      client.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY");

      var response = await client.GetStringAsync("https://api.apikodu.com/api/v1/math/unitconvert");
      Console.WriteLine(response);
  
  
      $response = file_get_contents('https://api.apikodu.com/api/v1/math/unitconvert', false, stream_context_create([
          'http' => [
              'header' => "x-api-key: YOUR_API_KEY"
          ]
      ]));

      print_r(json_decode($response, true));
  
  
      curl -X GET 'https://api.apikodu.com/api/v1/math/unitconvert' \
        -H 'x-api-key: YOUR_API_KEY'
  

Start building in minutes

Create a free account, get your API key and send your first request in minutes.

Get started free