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

Stock_Market_API is addded #456

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion New_APIs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
|[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|
|[Weather_Forecast_API](./Weather_Forecast_API/)|This demonstrates we can know weather report via api and spefic locactions only|
|[Weather_Forecast_API](./Weather_Forecast_API/)|This demonstrates we can know weather report via api and spefic locactions only|
|[Stock_Market_API](./Stock_Market_API/)|This demonstrates we can know Stock Market information report via api|
28 changes: 28 additions & 0 deletions New_APIs/Stock_Market_API/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Stock Market API Web App

This project is a simple web application that fetches stock market data for a given stock symbol using a public API.

## Features

- Fetch and display current stock price, symbol, and price change.
- User-friendly interface with input field and button.

## Technologies Used

- HTML
- CSS
- JavaScript

## Setup and Usage

1. Clone the repository or download the files.
2. Open `index.html` in a web browser.
3. Enter a stock symbol (e.g., `AAPL` for Apple) and click "Get Stock Data" to fetch the stock data.

## API Key

To use this project, you'll need to sign up for an API key from a stock market data provider like Alpha Vantage, Finnhub, etc. Replace `'your_api_key'` in `script.js` with your actual API key.

## License

This project is open source and available under the MIT License.
19 changes: 19 additions & 0 deletions New_APIs/Stock_Market_API/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stock Market API</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Stock Market API</h1>
<input type="text" id="stock-symbol" placeholder="Enter Stock Symbol">
<button id="fetch-data">Get Stock Data</button>
<div id="stock-data"></div>
</div>

<script src="script.js"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions New_APIs/Stock_Market_API/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
document.getElementById('fetch-data').addEventListener('click', () => {
const stockSymbol = document.getElementById('stock-symbol').value.toUpperCase();
const apiKey = 'your_api_key'; // Replace with your actual API key
const apiUrl = `https://api.example.com/stock/${stockSymbol}?apikey=${apiKey}`;

fetch(apiUrl)
.then(response => response.json())
.then(data => {
const stockDataDiv = document.getElementById('stock-data');
if (data.error) {
stockDataDiv.innerHTML = `<p>${data.error}</p>`;
} else {
stockDataDiv.innerHTML = `
<p><strong>Symbol:</strong> ${data.symbol}</p>
<p><strong>Price:</strong> $${data.price}</p>
<p><strong>Change:</strong> ${data.change}%</p>
`;
}
})
.catch(error => {
console.error('Error fetching stock data:', error);
});
});
46 changes: 46 additions & 0 deletions New_APIs/Stock_Market_API/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.container {
background: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
text-align: center;
}

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

input {
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
margin-right: 10px;
}

button {
padding: 10px 15px;
background-color: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #218838;
}

#stock-data {
margin-top: 20px;
}
Loading