Skip to main content

A powerful unit conversion library with CLI and API support

Project description

Conversion Unit Library

CLI Usage Demo

Unit Conversion CLI

REST API Usage Demo

Unit Conversion REST API

📌 Overview

A powerful Python library for unit conversion, supporting CLI and REST API. Convert units effortlessly for length, weight, volume, time, speed, and more!

🔥 Features

  • CLI Support: Run conversions from the command line
  • FastAPI REST API: Convert units via HTTP requests
  • Live API on Render: Hosted API accessible online
  • Comprehensive Units: Includes length, mass, volume, temperature, energy, and more
  • Custom Units: Add your own conversions dynamically

🚀 Installation

pip install conversion_unit

🔧 Usage

1️⃣ CLI Mode

convert 5 km to m
# Output: 5000.0

2️⃣ Python Library

from conversion_unit import convert
result = convert(5, "km", "m")
print(result)  # 5000.0

3️⃣ Local REST API Mode

Run the API server:

python -m conversion_unit

Then access:

GET http://localhost:8000/convert?value=5&from_unit=km&to_unit=m

Response:

{ "result": 5000.0 }

4️⃣ Live API on Render

Your API is hosted on Render! You can access it directly:

GET https://conversion-unit-api.onrender.com/convert?value=5&from_unit=km&to_unit=m

Example Response:

{ "result": 5000.0 }

📜 License

This project is licensed under the MIT License.

🌍 Contribute

Pull requests are welcome! Open an issue to suggest features or improvements.

⭐ Support the Project

If you find this project useful, give it a ⭐ on GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conversion_unit-1.0.3.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file conversion_unit-1.0.3.tar.gz.

File metadata

  • Download URL: conversion_unit-1.0.3.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for conversion_unit-1.0.3.tar.gz
Algorithm Hash digest
SHA256 23493f089b61767e1ccbf86d85196923b378425564b121e7bba80b55fa898544
MD5 87adb5474a81bb6cd134b1f21e80e1b2
BLAKE2b-256 df0174fff72fa2317a18b917b656a53e432997e949005a7587f3a4069b3d853a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page