From d609ab2e3d723220a66baecaf32a7448ebad9dd9 Mon Sep 17 00:00:00 2001 From: AmruthaPariprolu Date: Sat, 10 Aug 2024 03:38:24 +0530 Subject: [PATCH] added --- New_APIs/Metric_Conversion_API/README.md | 34 +++++++++++++ New_APIs/Metric_Conversion_API/index.html | 45 +++++++++++++++++ New_APIs/Metric_Conversion_API/index.js | 35 +++++++++++++ New_APIs/Metric_Conversion_API/manifest.json | 20 ++++++++ .../Metric_Conversion_API/package-lock.json | 13 +++++ New_APIs/Metric_Conversion_API/package.json | 17 +++++++ New_APIs/Metric_Conversion_API/styles.css | 50 +++++++++++++++++++ 7 files changed, 214 insertions(+) create mode 100644 New_APIs/Metric_Conversion_API/README.md create mode 100644 New_APIs/Metric_Conversion_API/index.html create mode 100644 New_APIs/Metric_Conversion_API/index.js create mode 100644 New_APIs/Metric_Conversion_API/manifest.json create mode 100644 New_APIs/Metric_Conversion_API/package-lock.json create mode 100644 New_APIs/Metric_Conversion_API/package.json create mode 100644 New_APIs/Metric_Conversion_API/styles.css diff --git a/New_APIs/Metric_Conversion_API/README.md b/New_APIs/Metric_Conversion_API/README.md new file mode 100644 index 0000000..d799938 --- /dev/null +++ b/New_APIs/Metric_Conversion_API/README.md @@ -0,0 +1,34 @@ +# 📏 Metric Conversion API + +## Overview + +The **Metric Conversion API** allows developers to convert values between different metric units such as meters, kilograms, liters, and Celsius. This API is useful for applications that need to perform metric conversions programmatically. + +## Features + +- **Length Conversion**: Convert between metric units like meters, centimeters, and kilometers. +- **Weight Conversion**: Convert between metric units like grams, kilograms, and milligrams. +- **Volume Conversion**: Convert between metric units like liters and milliliters. +- **Temperature Conversion**: Convert temperatures between Celsius and Kelvin. + +## Getting Started + +### Prerequisites + +- **API Key**: Obtain an API key by signing up on the Metric Conversion API website. + +### Installation + +To use the Metric Conversion API in a web application, follow these steps: + +1. **Obtain Your API Key**: After signing up, you will receive an API key. + +2. **Make API Requests**: Use the API key to authenticate your requests to the Metric Conversion API endpoint. + +3. **Sample Request**: + ```bash + curl -X GET "https://api.metricconversion.com/v1/convert?from=meters&to=feet&amount=10" \ + -H "Authorization: Bearer YOUR_API_KEY" + +### Contributor +### Amrutha Pariprolu \ No newline at end of file diff --git a/New_APIs/Metric_Conversion_API/index.html b/New_APIs/Metric_Conversion_API/index.html new file mode 100644 index 0000000..9e19d32 --- /dev/null +++ b/New_APIs/Metric_Conversion_API/index.html @@ -0,0 +1,45 @@ + + + + + + + Metric Conversion API App + + + +
+

Metric Conversion API App

+
+
+
+ + + + +
+
+
+ + + diff --git a/New_APIs/Metric_Conversion_API/index.js b/New_APIs/Metric_Conversion_API/index.js new file mode 100644 index 0000000..27642a7 --- /dev/null +++ b/New_APIs/Metric_Conversion_API/index.js @@ -0,0 +1,35 @@ +const apiKey = 'YOUR_API_KEY'; // Replace with your Metric Conversion API key +const endpoint = 'https://api.metricconversion.com/v1/convert'; + +document.getElementById('conversion-form').addEventListener('submit', function(event) { + event.preventDefault(); + const amount = document.getElementById('amount').value; + const fromUnit = document.getElementById('from-unit').value; + const toUnit = document.getElementById('to-unit').value; + + if (amount && fromUnit && toUnit) { + fetch(`${endpoint}?from=${fromUnit}&to=${toUnit}&amount=${amount}`, { + method: 'GET', + headers: { + 'Authorization': `Bearer ${apiKey}` + } + }) + .then(response => response.json()) + .then(data => { + const resultContainer = document.getElementById('result'); + if (data.result) { + resultContainer.innerHTML = ` +

Conversion Result:

+

${amount} ${fromUnit} is equal to ${data.result} ${toUnit}

+ `; + } else { + resultContainer.innerHTML = '

Conversion failed. Please check your input and try again.

'; + } + }) + .catch(error => { + console.error('Error fetching conversion results:', error); + const resultContainer = document.getElementById('result'); + resultContainer.innerHTML = '

An error occurred while fetching conversion results.

'; + }); + } +}); diff --git a/New_APIs/Metric_Conversion_API/manifest.json b/New_APIs/Metric_Conversion_API/manifest.json new file mode 100644 index 0000000..affd518 --- /dev/null +++ b/New_APIs/Metric_Conversion_API/manifest.json @@ -0,0 +1,20 @@ +{ + "name": "Metric Conversion API App", + "short_name": "Metric Converter", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#000000", + "icons": [ + { + "src": "icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/New_APIs/Metric_Conversion_API/package-lock.json b/New_APIs/Metric_Conversion_API/package-lock.json new file mode 100644 index 0000000..88004fe --- /dev/null +++ b/New_APIs/Metric_Conversion_API/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "metric-conversion-api-app", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "metric-conversion-api-app", + "version": "1.0.0", + "license": "MIT" + } + } +} diff --git a/New_APIs/Metric_Conversion_API/package.json b/New_APIs/Metric_Conversion_API/package.json new file mode 100644 index 0000000..86ece30 --- /dev/null +++ b/New_APIs/Metric_Conversion_API/package.json @@ -0,0 +1,17 @@ +{ + "name": "metric-conversion-api-app", + "version": "1.0.0", + "description": "A simple web app that integrates with Metric Conversion API for unit conversion functionality.", + "main": "index.js", + "scripts": { + "start": "echo 'No start script defined'" + }, + "keywords": [ + "metric", + "conversion", + "api", + "web" + ], + "author": "Amrutha", + "license": "MIT" +} diff --git a/New_APIs/Metric_Conversion_API/styles.css b/New_APIs/Metric_Conversion_API/styles.css new file mode 100644 index 0000000..39be748 --- /dev/null +++ b/New_APIs/Metric_Conversion_API/styles.css @@ -0,0 +1,50 @@ +body { + font-family: Arial, sans-serif; + background-color: #f5f5f5; + margin: 0; + padding: 0; + display: flex; + flex-direction: column; + align-items: center; +} + +header { + background-color: #000; + color: #fff; + width: 100%; + text-align: center; + padding: 10px; +} + +main { + margin-top: 20px; + width: 80%; + max-width: 800px; +} + +#conversion-form { + display: flex; + flex-direction: column; + align-items: center; +} + +input, select, button { + margin: 10px; + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; +} + +button { + background-color: #007bff; + color: #fff; + cursor: pointer; +} + +button:hover { + background-color: #0056b3; +} + +#result { + margin-top: 20px; +}