Skip to content

Commit

Permalink
Merge pull request #387 from pallasivasai/crypto906
Browse files Browse the repository at this point in the history
Cryptocurrency_API is added
  • Loading branch information
Kritika30032002 authored Aug 9, 2024
2 parents d8c3da1 + 714f949 commit 1715de4
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 0 deletions.
27 changes: 27 additions & 0 deletions New_APIs/Cryptocurrency_API/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Cryptocurrency API

This project is a simple web application that fetches and displays the current price of a cryptocurrency using a public API.

## Features

- Input a cryptocurrency name to fetch its current price in USD.
- Display the fetched data on the web page.

## Technologies Used

- HTML
- CSS
- JavaScript
- [CoinGecko API](https://www.coingecko.com/en/api)

## How to Run

1. Clone the repository or download the files.
2. Open the `index.html` file in your web browser.
3. Enter a cryptocurrency name (e.g., `bitcoin`, `ethereum`) in the input box and click the "Get Data" button to see the current price.

## Example Usage

- Input: `bitcoin`
- Output: `BITCOIN: $40000`

18 changes: 18 additions & 0 deletions New_APIs/Cryptocurrency_API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cryptocurrency API</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Cryptocurrency API</h1>
<input type="text" id="cryptoInput" placeholder="Enter Cryptocurrency (e.g., bitcoin)">
<button onclick="fetchCryptoData()">Get Data</button>
<div id="cryptoData"></div>
</div>
<script src="script.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions New_APIs/Cryptocurrency_API/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function fetchCryptoData() {
const cryptoName = document.getElementById('cryptoInput').value.toLowerCase();
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${cryptoName}&vs_currencies=usd`;

fetch(url)
.then(response => response.json())
.then(data => {
if (data[cryptoName]) {
document.getElementById('cryptoData').innerHTML = `
<p><strong>${cryptoName.toUpperCase()}:</strong> $${data[cryptoName].usd}</p>
`;
} else {
document.getElementById('cryptoData').innerHTML = `<p>Cryptocurrency not found. Please try again.</p>`;
}
})
.catch(error => {
document.getElementById('cryptoData').innerHTML = `<p>There was an error fetching the data.</p>`;
console.error('Error fetching the cryptocurrency data:', error);
});
}
51 changes: 51 additions & 0 deletions New_APIs/Cryptocurrency_API/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.container {
text-align: center;
background: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
margin-bottom: 20px;
color: #333;
}

input[type="text"] {
padding: 10px;
font-size: 16px;
width: 250px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}

button {
padding: 10px 20px;
font-size: 16px;
border: none;
border-radius: 5px;
background-color: #5cb85c;
color: #fff;
cursor: pointer;
}

button:hover {
background-color: #4cae4c;
}

#cryptoData {
margin-top: 20px;
font-size: 18px;
color: #555;
}
1 change: 1 addition & 0 deletions New_APIs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
|[Payment API](./Payment_API/)|This demonstrates how to integrate PayPal API for online payments. It handles payment success and cancellation scenarios.|
|[Social Media Analytics API](./Social_Media_Analytics_AP/)|This demonstrates how to create a Social Media Analytics API to retrieve user engagement data like posts, likes, comments, and shares.|
|[Voice_Recognition_API](./Voice_Recognition_API/)|This demonstrates how a meachine retrieve user engagement only Voice|
|[Cryptocurrency_API](./Cryptocurrency_API/)|This demonstrates how a convert Cryptocurrency and spefic currency to dollars only|

0 comments on commit 1715de4

Please sign in to comment.