Units API

Unit of measure conversion API

Download .zip Download .tar.gz View on GitHub

Units of measure conversion API, based on the work done by Units API for Drupal, though decoupled from Drupal and usable as a hosted service as well as a PHP library.

Usage as a Hosted Service:

Conversion Request:

GET http://host/convert.php?value=5&from=km&to=miles


  "from": {
    "value": "5",
    "unit": {
      "singular": "kilometer",
      "plural": "kilometers",
      "symbol": "km"
  "to": {
    "value": "3.107",
    "unit": {
      "singular": "mile",
      "plural": "miles",
      "symbol": "mi"

Usage as a PHP Library:


$api = new UnitsAPI();

$result = $api->convert(5, 'kg', 'lb');

// $result is an associative array with the same structure as the HTTP JSON response