Skip to content

adenjonah/TicketMasterBot

Repository files navigation

Ticketmaster Bot

Ticketmaster Bot is a Discord bot designed to alert users every time a new event becomes available on Ticketmaster. Built for a ticket resale company based in NYC, it ensures users receive timely updates about upcoming events and provides powerful tools for managing event notifications.

Features

  • Event Alerts: Automatically notifies a Discord server when new events are added to Ticketmaster. alert example

  • User Commands:

    • !next: Displays events with tickets going on sale next.
      !next example
    • !addartist <artistID>: Marks an artist as notable, sending their events to a dedicated high-profile channel.
      !addartist example
  • API Crawlers: Continuously fetch new events from Ticketmaster’s API for four regions in North America.

Tech Stack

Architecture

The project is composed of two key components:

  1. API Crawlers: Four Python scripts, each assigned to a specific North American region, poll the Ticketmaster API every minute and store new events in a PostgreSQL database.
  2. Bot Script: The Discord bot retrieves unsent events from the database, posts them in designated channels, and handles user commands.
    Example request:
    https://app.ticketmaster.com/discovery/v2/events?apikey=YOUR_API_KEY&source=ticketmaster&locale=*&size=199&page=1&onsaleStartDateTime=2024-12-27T00:00:00Z&classificationId=CONCERTS&onsaleOnAfterStartDate=DATE&sort=onSaleStartDate,asc&latlong=CENTER&radius=DIST&unit=miles

Challenges & Solutions

  • Rate Limits: The Ticketmaster API enforces a rate limit of 1000 events returned per query.
    image

    • Solution: Run five separate Heroku servers (four crawlers and one bot) to distribute requests and avoid exceeding rate limits.
      North American Regions
  • Storage Efficiency: Optimized database structure to handle high-frequency updates and large datasets effectively.
    image

Future Development

  • Expand coverage to include events from other continents.
  • Optimize database queries for better performance.
  • Add new Discord commands and enhance logging mechanisms.
  • Improve bot scalability and error handling.

Installation

  1. Clone the repository:

    git clone https://github.com/adenjonah/TicketMasterBot.git
  2. Install dependencies:

    pip install -r requirements.txt
  3. Set up your environment variables:

    • TICKETMASTER_API_KEY
    • DISCORD_CHANNEL_ID
    • DISCORD_CHANNEL_ID_TWO
    • DISCORD_BOT_TOKEN
    • DATABASE_URL
    • DEBUG_LOGS (1 if on, 0 if off)
    • CENTER_POINT (long, lat of the zone you want to crawl)
    • RADIUS (in miles)
    • UNIT=miles
    • REDIRECT_URI=http://localhost
      Example .env
       TICKETMASTER_API_KEY='P7v8iurhq2a9r84o84irqo2uhq'
       DISCORD_BOT_TOKEN='MKSEalfnj87yBbE8.GHQ_Cx.KHGbkFHBFYUBFI-ri_XY'
       DISCORD_CHANNEL_ID='3795263749501923847509'
       DISCORD_CHANNEL_ID_TWO='73425974283745975392785'
       REDIRECT_URI='http://localhost'
       DATABASE_URL='postgres://7stfuastdg88:utaf8sfiasgig9asiygfouasgf0.cluster-s78syag9.us-east-2.rds.amazonaws.com:26739/aiysgfyasg98f'
       DEBUG_LOGS='1'
       CENTER_POINT=43.89789,-72.84782
       RADIUS=685
       UNIT=miles
      
  4. Deploy to Heroku or run locally using the provided scripts (run newbot.py and crawler.py at the same time).

Usage

  • Add the bot to your Discord server.
  • Configure the database with your Ticketmaster API regions and preferences via environment variables.
  • Start receiving real-time alerts and use commands like !next and !addartist to interact with the bot.

Repository

Find the source code and deployment instructions here.

About the Developer

This project was developed by adenjonah as a solo initiative, requiring approximately 30 hours of work, including iterations. For inquiries or collaboration, feel free to reach out via GitHub or the contacts in my profile.

About

Realtime event sale updates

Resources

Stars

Watchers

Forks