diff --git a/Existing_API_Collection/GlobalHolidayAPI/README.md b/Existing_API_Collection/GlobalHolidayAPI/README.md new file mode 100644 index 0000000..1b69b71 --- /dev/null +++ b/Existing_API_Collection/GlobalHolidayAPI/README.md @@ -0,0 +1,24 @@ +GlobalHoliday API: +-The Calendarific Global Holidays API covers over 230 countries and 3000 states around the world. + An API key is required for every request to the Holiday API. +-It enables Access to Worldwide Holiday Data,saves times,provides Accuracy and Reliability. +-This API can be useful for promoting cultural awareness and inclusivity by providing information about holidays and celebrations from diverse cultures and regions. + +Future Scope: +-The Global Holiday API may continue to add more countries and regions to their holiday databases, ensuring broader global coverage. +-Improvements in data accuracy and real-time updates will be a major focus. +-Integration with AI and automation tools can help businesses predict and plan for holiday-related events and trends + +Implementation: +-The JavaScript code contains an HTTP request to the Global Holiday API's along with country code and authenticated api key, it fetches list of holidays for selected country. + +Tech Stacks used: + - HTML (frontend) + - CSS (styling) + - Javascript (API Implementation) + +Output : +![Output](image.png) + +Reference: +https://calendarific.com/api-documentation \ No newline at end of file diff --git a/Existing_API_Collection/GlobalHolidayAPI/image.png b/Existing_API_Collection/GlobalHolidayAPI/image.png new file mode 100644 index 0000000..e9c27b5 Binary files /dev/null and b/Existing_API_Collection/GlobalHolidayAPI/image.png differ diff --git a/Existing_API_Collection/GlobalHolidayAPI/index.html b/Existing_API_Collection/GlobalHolidayAPI/index.html new file mode 100644 index 0000000..f684b95 --- /dev/null +++ b/Existing_API_Collection/GlobalHolidayAPI/index.html @@ -0,0 +1,42 @@ + + + + + + Holiday List + + + +
+

Holiday List For Countries

+
+
+
+ + + +
+
+ +
+
+ + + diff --git a/Existing_API_Collection/GlobalHolidayAPI/script.js b/Existing_API_Collection/GlobalHolidayAPI/script.js new file mode 100644 index 0000000..59ae765 --- /dev/null +++ b/Existing_API_Collection/GlobalHolidayAPI/script.js @@ -0,0 +1,51 @@ +document.addEventListener("DOMContentLoaded", () => { + const searchButton = document.getElementById("search-button"); + const countryInput = document.getElementById("country-input"); + const holidaysList = document.getElementById("holidays-list"); + + searchButton.addEventListener("click", () => { + const countryCode = countryInput.value; + + if (countryCode) { + fetchHolidays(countryCode); + } + }); + + function fetchHolidays(countryCode) { + //API KEY + const apiKey = 'akio9k5qVkY8dCwDGw657ZGC3M8LWOcY'; + const apiUrl = `https://calendarific.com/api/v2/holidays?country=${countryCode}&year=2023&api_key=${apiKey}`; + + fetch(apiUrl) + .then(response => { + if (response.ok) { + return response.json(); + } else { + throw new Error('Unable to fetch holidays.'); + } + }) + .then(data => { + displayHolidays(data.response.holidays); + }) + .catch(error => { + console.error(error); + holidaysList.innerHTML = "

Error fetching holidays.

"; + }); + } + + function displayHolidays(holidays) { + holidaysList.innerHTML = ""; + + if (holidays.length === 0) { + holidaysList.innerHTML = "

No holidays found for this year.

"; + } else { + //traversing holiday list and printing it + holidays.forEach(holiday => { + const listItem = document.createElement("div"); + listItem.className = "holiday-item"; + listItem.innerHTML = `${holiday.date.iso}: ${holiday.name}`; + holidaysList.appendChild(listItem); + }); + } + } +}); diff --git a/Existing_API_Collection/GlobalHolidayAPI/style.css b/Existing_API_Collection/GlobalHolidayAPI/style.css new file mode 100644 index 0000000..0ae385d --- /dev/null +++ b/Existing_API_Collection/GlobalHolidayAPI/style.css @@ -0,0 +1,55 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + background-color: #f0f0f0; +} + +header { + background-color: #007BFF; + color: white; + padding: 20px; + text-align: center; + font-size: 32px; +} + +main { + max-width: 800px; + margin: 0 auto; + padding: 20px; + background-color: white; + border-radius: 5px; + box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3); + text-align: center; +} + +label { + font-size: 18px; +} + +#country-input { + padding: 10px; + margin: 10px 0; + border: 1px solid #ccc; + border-radius: 5px; +} + +#search-button { + background-color: #007BFF; + color: white; + border: none; + border-radius: 5px; + padding: 10px 20px; + font-size: 16px; + cursor: pointer; + transition: background-color 0.3s ease; +} + +#search-button:hover { + background-color: #0056b3; +} + +#holidays-list { + margin-top: 20px; + text-align: left; +} \ No newline at end of file