https://github.com/ajay-dhangar/gold-price-tracker
https://github.com/ajay-dhangar/gold-price-tracker
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ajay-dhangar/gold-price-tracker
- Owner: ajay-dhangar
- License: mit
- Created: 2024-08-15T08:41:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-15T09:18:22.000Z (about 1 year ago)
- Last Synced: 2024-12-06T22:52:14.532Z (11 months ago)
- Language: CSS
- Homepage: https://ajay-dhangar.github.io/gold-price-tracker/
- Size: 48.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gold and Silver Prices Web App



## Overview
The **Gold and Silver Prices Web App** is a simple, responsive web application that displays the latest prices of Gold and Silver in USD. The prices are fetched from the [GoldAPI](https://www.goldapi.io/) and displayed dynamically on the page.
## Features
- **Live Gold Prices**: Fetches and displays the latest Gold prices.
- **Live Silver Prices**: Fetches and displays the latest Silver prices.
- **Responsive Design**: Optimized for both desktop and mobile devices.
## Demo
Check out the live demo: [Gold and Silver Prices Web App](https://ajay-dhangar.github.io/gold-price-tracker/)
## Technologies Used
- **HTML**: For structuring the web page.
- **CSS**: For styling the UI components and layout.
- **JavaScript**: For fetching the data from the API and updating the UI.
## Installation
First, ensure you have the forked repository on your local machine. Then, follow these steps:
1. Clone the repository:
```bash
git clone https://github.com/your-username/gold-price-tracker.git
```
2. Navigate to the project directory:
```bash
cd gold-price-tracker
```
3. Open the `index.html` file in your preferred web browser.
## Usage
- Simply open the app in a web browser to view the latest prices of Gold and Silver.
- The app automatically updates the prices each time it is loaded.
## Code Structure
- **index.html**: The main HTML file containing the structure of the web page.
- **styles.css**: The CSS file containing the styles and layout of the web app.
- **script.js**: The JavaScript file responsible for fetching data from the API and updating the DOM.
## API Integration
This project integrates with the [GoldAPI](https://www.goldapi.io/) to fetch live prices of Gold and Silver.
```javascript
var myHeaders = new Headers();
myHeaders.append("x-access-token", "your-access-token");
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
// Fetching Gold Price
fetch("https://www.goldapi.io/api/XAU/USD", requestOptions)
.then(response => response.json())
.then(result => {
document.getElementById("goldPrice").innerHTML = "Gold Price: $" + result.price.toFixed(2);
})
.catch(error => console.log('error', error));
// Fetching Silver Price
fetch("https://www.goldapi.io/api/XAG/USD", requestOptions)
.then(response => response.json())
.then(result => {
document.getElementById("silverPrice").innerHTML = "Silver Price: $" + result.price.toFixed(2);
})
.catch(error => console.log('error', error));
```
## Contributing
Contributions are welcome! Please follow these steps to contribute:
1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Make your changes and commit them (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature-branch`).
5. Open a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Contact
If you have any questions, feel free to reach out:
- **Name**: Ajay Dhangar
- **Email**: ajaydhangar49@gmail.com
- **GitHub**: [Ajay-Dhangar](https://github.com/Ajay-Dhangar)
- **LinkedIn**: [Ajay Dhangar](https://www.linkedin.com/in/ajay-dhangar/)