{"id":21068949,"url":"https://github.com/cloudprivacylabs/units","last_synced_at":"2025-06-16T23:36:10.413Z","repository":{"id":112728725,"uuid":"455247572","full_name":"cloudprivacylabs/units","owner":"cloudprivacylabs","description":"Unified codes for units of measure Go front end","archived":false,"fork":false,"pushed_at":"2022-06-04T04:18:46.000Z","size":5345,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T02:23:33.617Z","etag":null,"topics":["measurements","ucum","units-measures-converter","units-of-measure"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudprivacylabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-02-03T16:46:12.000Z","updated_at":"2023-07-13T00:25:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf2c043a-a094-48b5-829f-4c360e4dadbb","html_url":"https://github.com/cloudprivacylabs/units","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":"0.26315789473684215","last_synced_commit":"ed6fb8b2326cbcc34fefe1784bae865d77c60c39"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cloudprivacylabs/units","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Funits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Funits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Funits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Funits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudprivacylabs","download_url":"https://codeload.github.com/cloudprivacylabs/units/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Funits/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260261703,"owners_count":22982698,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["measurements","ucum","units-measures-converter","units-of-measure"],"created_at":"2024-11-19T18:29:39.416Z","updated_at":"2025-06-16T23:36:10.375Z","avatar_url":"https://github.com/cloudprivacylabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Units\n\nThis is a RESTful front-end to the Unified Code for Units of Measure\n(UCUM) library that implements the measure service functionality for\nLayered Schema Architecture. It extends the UCUM interface with a\nregular-expression based unit matching functionality to extend UCUM to\nhandle common nonstandard measure representations, such as 5'6\" for\nlength.\n\nThe homepage for UCUM is: https://ucum.nlm.nih.gov/\n\n## Building/Running\n\nThis service contains a NodeJS application (the UCUM implementation)\nand a Go API front-end that deals with normalizations not supported by\nUCUM. Easiest way to run it is using a Docker image. To build, run:\n\n```\ndocker build -t units:latest .\n```\n\nThe docker image runs two servers. The UCUM server is running on port\n8080, and the Go front-end server is running on port 8081. Normally\nyou would want to expose the 8081 service:\n\nTo run:\n\n```\ndocker run -p 9090:8081 units:latest\n```\n\nThis will make the `units` service available on `localhost:9090`.\n\n## The API\n\nThere are three endpoints provided by this service:\n\n### Unit normalization\n\n```\ncurl http://localhost:9090/unit?value=5'6\"\n```\n\nThis will return:\n\n```\n{\n  \"unit\": \"[in_i]\",\n  \"valid\": true,\n  \"value\": \"66\"\n}\n```\n\nThis output means that the unit input is valid, its unit is `[in_i]`,\nwhich is the UCUM code for inch, and its value is `66`, meaning the\nvalue is `66 inch`.\n\nThe input:\n\n```\ncurl http://localhost:9090/unit?value=12meter\n```\n\nThe output is:\n\n```\n{\n  \"msg\": \"The UCUM code for meter is m.\\nDid you mean m?\",\n  \"unit\": \"m\",\n  \"valid\": false,\n  \"value\": \"12\"\n}\n```\n\nNote that the unit conversion is done, but it is marked as invalid.\n\n### Unit Validation\n\nThis API directly calls the UCUM implementation to validate a unit.\n\n```\ncurl http://localhost:9090/validate?unit=meter\n\n{\n  \"status\": \"invalid\",\n  \"ucumCode\": \"m\",\n  \"unit\": {\n    \"code\": \"m\",\n    \"name\": \"meter\",\n    \"guidance\": \"unit of length = 1.09361 yards\"\n  },\n  \"msg\": [\n    \"The UCUM code for meter is m.\\nDid you mean m?\"\n  ]\n}\n```\n\n### Unit Conversion\n\nThis API directly calls the UCUM conversion API.\n\n```\ncurl http://localhost:9090/convert?value=1\u0026unit=cm\u0026output=m\n\n{\n  \"status\": \"succeeded\",\n  \"toVal\": 0.01,\n  \"msg\": [\n    \n  ],\n  \"fromUnit\": {\n    \"isBase_\": true,\n    \"name_\": \"centimeter\",\n    \"csCode_\": \"cm\",\n    \"ciCode_\": \"CM\",\n    \"property_\": \"length\",\n    \"magnitude_\": 0.01,\n    \"dim_\": {\n      \"dimVec_\": [\n        1,\n        0,\n        0,\n        0,\n        0,\n        0,\n        0\n      ]\n    },\n    \"printSymbol_\": \"cm\",\n    \"class_\": null,\n    \"isMetric_\": false,\n    \"variable_\": \"L\",\n    \"cnv_\": null,\n    \"cnvPfx_\": 1,\n    \"isSpecial_\": false,\n    \"isArbitrary_\": false,\n    \"moleExp_\": 0,\n    \"synonyms_\": \"centimeters; centimetres\",\n    \"source_\": \"LOINC\",\n    \"loincProperty_\": \"Len\",\n    \"category_\": \"Clinical\",\n    \"guidance_\": null,\n    \"csUnitString_\": null,\n    \"ciUnitString_\": null,\n    \"baseFactorStr_\": null,\n    \"baseFactor_\": null,\n    \"defError_\": false\n  },\n  \"toUnit\": {\n    \"isBase_\": true,\n    \"name_\": \"meter\",\n    \"csCode_\": \"m\",\n    \"ciCode_\": \"M\",\n    \"property_\": \"length\",\n    \"magnitude_\": 1,\n    \"dim_\": {\n      \"dimVec_\": [\n        1,\n        0,\n        0,\n        0,\n        0,\n        0,\n        0\n      ]\n    },\n    \"printSymbol_\": \"m\",\n    \"class_\": null,\n    \"isMetric_\": false,\n    \"variable_\": \"L\",\n    \"cnv_\": null,\n    \"cnvPfx_\": 1,\n    \"isSpecial_\": false,\n    \"isArbitrary_\": false,\n    \"moleExp_\": 0,\n    \"synonyms_\": \"meters; metres; distance\",\n    \"source_\": \"UCUM\",\n    \"loincProperty_\": \"Len\",\n    \"category_\": \"Clinical\",\n    \"guidance_\": \"unit of length = 1.09361 yards\",\n    \"csUnitString_\": null,\n    \"ciUnitString_\": null,\n    \"baseFactorStr_\": null,\n    \"baseFactor_\": null,\n    \"defError_\": false\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudprivacylabs%2Funits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudprivacylabs%2Funits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudprivacylabs%2Funits/lists"}