shrimpza / units-api

Unit of measure conversion API

Home Page:https://shrimpza.github.io/units-api/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Units API

Build Status

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

Response:

{
  "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:

require_once('path/to/units-api/unitsapi.php');

$api = new UnitsAPI();

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

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

About

Unit of measure conversion API

https://shrimpza.github.io/units-api/

License:GNU General Public License v2.0


Languages

Language:PHP 100.0%