Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit convertor API added #438

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions New_APIs/Unit_Convertor_API/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 🔄 Unit Converter API

## Overview

The **Unit Converter API** provides functionality to convert between different units of measurement, such as length, weight, temperature, and more. This API allows developers to integrate unit conversion features into their applications easily.

## Features

- **Length Conversion**: Convert between units of length, such as meters, kilometers, feet, and inches.
- **Weight Conversion**: Convert between units of weight, such as grams, kilograms, pounds, and ounces.
- **Temperature Conversion**: Convert between temperature units, such as Celsius, Fahrenheit, and Kelvin.
- **Customizable**: Convert between various other units based on the API’s capabilities.

## Getting Started

### Prerequisites

- **API Key**: You will need an API key to access the Unit Converter API. Obtain an API key by [signing up](https://unitconvertapi.com/) on the Unit Converter API website.

### Installation

To use the Unit Converter 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 Unit Converter API endpoint.

3. **Sample Request**:
```bash
curl -X GET "https://api.unitconvertapi.com/v1/convert?from=meters&to=feet&amount=10" \
-H "Authorization: Bearer YOUR_API_KEY"


### contributor
### Amrutha Pariprolu
40 changes: 40 additions & 0 deletions New_APIs/Unit_Convertor_API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unit Converter API App</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>Unit Converter API App</h1>
</header>
<main>
<form id="conversion-form">
<input type="number" id="amount" placeholder="Amount" required>
<select id="from-unit">
<option value="meters">Meters</option>
<option value="feet">Feet</option>
<option value="kilograms">Kilograms</option>
<option value="pounds">Pounds</option>
<option value="celsius">Celsius</option>
<option value="fahrenheit">Fahrenheit</option>
</select>
<select id="to-unit">
<option value="feet">Feet</option>
<option value="meters">Meters</option>
<option value="pounds">Pounds</option>
<option value="kilograms">Kilograms</option>
<option value="fahrenheit">Fahrenheit</option>
<option value="celsius">Celsius</option>
</select>
<button type="submit">Convert</button>
</form>
<div id="result"></div>
</main>
<script src="index.js"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions New_APIs/Unit_Convertor_API/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const apiKey = 'YOUR_API_KEY'; // Replace with your Unit Converter API key
const endpoint = 'https://api.unitconvertapi.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 = `
<h3>Conversion Result:</h3>
<p>${amount} ${fromUnit} is equal to ${data.result} ${toUnit}</p>
`;
} else {
resultContainer.innerHTML = '<p>Conversion failed. Please check your input and try again.</p>';
}
})
.catch(error => {
console.error('Error fetching conversion results:', error);
const resultContainer = document.getElementById('result');
resultContainer.innerHTML = '<p>An error occurred while fetching conversion results.</p>';
});
}
});
20 changes: 20 additions & 0 deletions New_APIs/Unit_Convertor_API/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Unit Converter API App",
"short_name": "Unit Converter App",
"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"
}
]
}
13 changes: 13 additions & 0 deletions New_APIs/Unit_Convertor_API/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions New_APIs/Unit_Convertor_API/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "unit-converter-api-app",
"version": "1.0.0",
"description": "A simple web app that integrates with Unit Converter API for unit conversion functionality.",
"main": "index.js",
"scripts": {
"start": "echo 'No start script defined'"
},
"keywords": [
"unit",
"converter",
"api",
"web"
],
"author": "Amrutha",
"license": "MIT"
}
50 changes: 50 additions & 0 deletions New_APIs/Unit_Convertor_API/styles.css
Original file line number Diff line number Diff line change
@@ -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;
}
Loading