https://github.com/westy92/holiday-event-api-go
The Official Holiday and Event API for Go
https://github.com/westy92/holiday-event-api-go
api calendar celebration checkiday date day event events federal go golang holiday-api holiday-calculation holidays holidays-api list month occurrence public year
Last synced: about 1 month ago
JSON representation
The Official Holiday and Event API for Go
- Host: GitHub
- URL: https://github.com/westy92/holiday-event-api-go
- Owner: westy92
- License: mit
- Created: 2022-09-01T05:08:23.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-25T04:26:49.000Z (7 months ago)
- Last Synced: 2025-03-30T13:04:32.921Z (2 months ago)
- Topics: api, calendar, celebration, checkiday, date, day, event, events, federal, go, golang, holiday-api, holiday-calculation, holidays, holidays-api, list, month, occurrence, public, year
- Language: Go
- Homepage: https://pkg.go.dev/github.com/westy92/holiday-event-api-go
- Size: 87.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# The Official Holiday and Event API for Go
[](https://pkg.go.dev/github.com/westy92/holiday-event-api-go)
[](https://github.com/westy92/holiday-event-api-go/actions)
[](https://codecov.io/gh/westy92/holiday-event-api-go)
[](https://github.com/sponsors/westy92)Industry-leading Holiday and Event API for Go. Over 5,000 holidays and thousands of descriptions. Trusted by the World’s leading companies. Built by developers for developers since 2011.
## Supported Go Versions
Latest version of the the Holiday and Event API supports last two Go major [releases](https://go.dev/doc/devel/release#policy) and might work with older versions.
## 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
go get github.com/westy92/holiday-event-api-go
```## Example
```go
import (
"fmt"holidays "github.com/westy92/holiday-event-api-go"
)func main() {
// Get a FREE API key from https://apilayer.com/marketplace/checkiday-api#pricing
client, err := holidays.New("")if err != nil {
fmt.Println(err)
return
}// Get Events for a given Date
events, err := client.GetEvents(holidays.GetEventsRequest{
// These parameters are the defaults but can be specified:
// Date: "today",
// Timezone: "America/Chicago",
// Adult: false,
})if err != nil {
fmt.Println(err)
return
}event := events.Events[0]
fmt.Printf("Today is %s! Find more information at: %s.\n", event.Name, event.Url)
fmt.Printf("Rate limit remaining: %d/%d (month).\n", events.RateLimit.RemainingMonth, events.RateLimit.LimitMonth)// Get Event Information
eventInfo, err := client.GetEventInfo(holidays.GetEventInfoRequest{
Id: event.Id,
// These parameters can be specified to calculate the range of eventInfo.Event.Occurrences
// Start: 2020,
// End: 2030,
})if err != nil {
fmt.Println(err)
return
}fmt.Printf("The Event's hashtags are %q.\n", eventInfo.Event.Hashtags)
// Search for Events
query := "pizza day"
search, err := client.Search(holidays.SearchRequest{
Query: query,
// These parameters are the defaults but can be specified:
// Adult: false,
})if err != nil {
fmt.Println(err)
return
}fmt.Printf("Found %d events, including %s, that match the query \"%s\".\n", len(search.Events), search.Events[0].Name, query)
}
```