https://github.com/westy92/holiday-event-api-rust
The Official Holiday and Event API for Rust
https://github.com/westy92/holiday-event-api-rust
api calendar celebration checkiday date day event events federal holiday-api holiday-calculation holidays holidays-api list month occurrence public rust rustlang year
Last synced: 26 days ago
JSON representation
The Official Holiday and Event API for Rust
- Host: GitHub
- URL: https://github.com/westy92/holiday-event-api-rust
- Owner: westy92
- License: mit
- Created: 2023-04-22T14:34:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-26T03:18:08.000Z (over 1 year ago)
- Last Synced: 2025-08-24T10:31:12.579Z (about 1 month ago)
- Topics: api, calendar, celebration, checkiday, date, day, event, events, federal, holiday-api, holiday-calculation, holidays, holidays-api, list, month, occurrence, public, rust, rustlang, year
- Language: Rust
- Homepage: https://crates.io/crates/holiday_event_api
- Size: 42 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# The Official Holiday and Event API for Rust
[](https://crates.io/crates/holiday_event_api)
[](https://github.com/westy92/holiday-event-api-rust/actions)
[](https://docs.rs/holiday_event_api)
[](https://codecov.io/gh/westy92/holiday-event-api-rust)
[](https://github.com/sponsors/westy92)Industry-leading Holiday and Event API for Rust. Over 5,000 holidays and thousands of descriptions. Trusted by the World’s leading companies. Built by developers for developers since 2011.
## Authentication
Access to the Holiday and Event API requires an API Key. You can get for one for FREE [here](https://apilayer.com/marketplace/checkiday-api#pricing), no credit card required! Note that free plans are limited. To access more data and have more requests, a paid plan is required.
## Installation
```console
cargo add holiday_event_api
```## Example
```rust
use holiday_event_api::{
model::{GetEventInfoRequest, GetEventsRequest, SearchRequest},
HolidayEventApi,
};#[tokio::main]
async fn main() {
// Get a FREE API key from https://apilayer.com/marketplace/checkiday-api#pricing
let client = HolidayEventApi::new("");if client.is_err() {
println!("{}", client.unwrap_err());
return;
}let client = client.unwrap();
// Get Events for a given Date
let events = client
.get_events(GetEventsRequest {
// These parameters are all optional. These are their defaults:
date: Some("today".into()),
adult: Some(false),
timezone: Some("America/Chicago".into()),
})
.await;if events.is_err() {
println!("{}", events.unwrap_err());
return;
}let events = events.unwrap();
let event = events.events.get(0).unwrap();
println!(
"Today is {}! Find more information at: {}.",
event.name, event.url
);
println!(
"Rate limit remaining: {}/{} (month).",
events.rate_limit.remaining_month, events.rate_limit.limit_month
);// Get Event Information
let event_info = client
.get_event_info(GetEventInfoRequest {
id: event.id.to_string(),
// These parameters can be specified to calculate the range of event_info.event.occurrences
start: None, // Some(2020),
end: None, // Some(2030),
})
.await;if event_info.is_err() {
println!("{}", event_info.unwrap_err());
return;
}let event_info = event_info.unwrap();
println!("The Event's hashtags are {:?}.", event_info.event.hashtags);
// Search for Events
let query = "pizza day";
let search = client
.search(SearchRequest {
query: query.into(),
// These parameters are the defaults but can be specified:
adult: None, // Some(true),
})
.await;if search.is_err() {
println!("{}", search.unwrap_err());
return;
}let search = search.unwrap();
println!(
"Found {} events, including {}, that match the query \"{}\".",
search.events.len(),
search.events.first().unwrap().name,
query
)
}
```