A go package to fetch ticket listings from the Twickets Live Feed.
Includes utilities to help filter the ticket listings and find the ones you want!
Powers (the similarly creatively named) twitchets, a tool to watch for event ticket listings on Twickets and notify you so you can snap them up! 🫰
go get -u github.com/ahobsonsayers/twigots
To use this tool, you will need a Twickets API key. Although Twickets doesn't provide a free API, you can easily obtain a key by following these steps:
- Visit the Twickets Live Feed
- Open your browser's Developer Tools (F12) and navigate to the Network tab
- Look for the GET request to
https://www.twickets.live/services/catalogue
and copy theapi_key
query parameter. You might need to refresh the page first if nothing appears in this tab.
This API key is not provided here due to liability concerns, but it appears to be a fixed, unchanging value.
package main
import (
"context"
"log"
"log/slog"
"time"
"github.com/ahobsonsayers/twigots"
)
func main() {
apiKey := "my_api_key"
// Fetch ticket listings
client := twigots.NewClient(nil) // Or use a custom http client
listings, err := client.FetchTicketListings(
context.Background(),
twigots.FetchTicketListingsInput{
// Required
APIKey: apiKey,
Country: twigots.CountryUnitedKingdom, // Only UK is supported at the moment
// Optional. See all options in godoc
CreatedBefore: time.Now(),
CreatedAfter: time.Now().Add(time.Duration(-5 * time.Minute)), // 5 mins ago
MaxNumber: 100,
},
)
if err != nil {
log.Fatal(err)
}
log.Printf("Fetched %d ticket listings", len(listings))
// Filter ticket listing for the ones we want
filteredListings, err := listings.Filter(
// Filter for listings of Hamilton tickets
twigots.Filter{Event: "Hamilton"},
// Also filter for listings of Coldplay tickets.
// Lets impose extra restrictions on these.
twigots.Filter{
Event: "Coldplay", // Required
EventSimilarity: 1, // Avoid false positives
Regions: []twigots.Region{
twigots.RegionLondon,
twigots.RegionSouth,
},
NumTickets: 2, // Exactly 2 tickets in the listing
MinDiscount: 0.1, // Discount of > 10%
},
)
if err != nil {
log.Fatal(err)
}
for _, listing := range filteredListings {
slog.Info(
"Ticket listing found matching a filter",
"Event", listing.Event.Name,
"NumTickets", listing.NumTickets,
"Price", listing.TotalPriceInclFee().String(),
"OriginalPrice", listing.OriginalTicketPrice().String(),
"URL", listing.URL(),
)
}
}
Because its a stupid mash up of Tickets and Go... and also why not?