World Cup Psychic: Automatically Predict World Cup Score In Purplelane App

3 minute read

Intro

The end of the world cup is finally getting near & everyone rushing to predict the final score of the game. I thought I would share an interesting thing I made just two weeks into the world cup. Since the start of it everyone & almost all the companies were posting predict and win score guessing competitions and among them was also the purple-lane app.

Purple-lane is this amazing reward program app based in Maldives that helps companies to enroll & manage their customers in their reward programs such as coupons, discounts & more.

I got signed up for the world-cup Foari that they were doing and started making predictions of the match of my own. Almost everything I predicted was wrong. And I was also missing matches because I wasn’t able to watch or keep up with the world-cup schedule. So thought of making the process automated.

Initial plan & Steps

  • Get all the Live fixtures from worldcup API
  • Get the fixtures to predict from PurpleLane API
  • Convert Local time ( Qatar Time) to Maldives Time
  • Mins Before prediction_closes_at equals to current time. Get the live score of the world cup fixture
  • Predict with for the given email with away team score & home team score
  • Send notification over telegram when the bot makes a prediction
  • Host & run the app periodically on server

So I looked under the hood of how purple-lane API worked & found the end-point to predict the score for the match & the live fixtures.

Sample fixture response from their API
 1{
 2			"id": 2414,
 3			"uuid": "97d6a6c5-9620-4a01-928d-76f26f22970d",
 4			"participant_id": "279",
 5			"fixture_id": 31,
 6			"home_team_score": "0",
 7			"away_team_score": "0",
 8			"status": 1,
 9			"prize_won": 0,
10			"won": 0,
11			"created_at": "2022-11-26T16:56:07.000000Z",
12			"updated_at": "2022-11-26T17:56:59.000000Z",
13			"fixture": {
14				"id": 31,
15				"uuid": "97c7a238-d1c0-469a-a150-16fd2d185e74",
16				"stage": "Group D",
17				"tournament_id": 1,
18				"home_team_id": 13,
19				"home_team_score": "2",
20				"away_team_id": 15,
21				"away_team_score": "1",
22				"prize": 2,
23				"prediction_closes_at": "2022-11-26T17:22:00.000000Z",
24				"kick_off_time": "2022-11-26T16:00:00.000000Z",
25				"match_status": 3,
26				"created_at": "2022-11-19T05:47:08.000000Z",
27				"updated_at": "2022-11-26T17:56:42.000000Z",
28				"date": "26-11-2022",
29				"time": "21:00:00",
30				"home_team": {
31					"id": 13,
32					"tournament_id": 1,
33					"name": "France",
34					"code": "FRA",
35					"logo": null,
36					"flag": "GH2ZVtbsLaTpS1WBCw22VY1jecILdFWmMsctsowb.png",
37					"created_at": "2022-11-16T02:56:09.000000Z",
38					"updated_at": "2022-11-16T02:56:09.000000Z"
39				},
40				"away_team": {
41					"id": 15,
42					"tournament_id": 1,
43					"name": "Denmark",
44					"code": "DEN",
45					"logo": null,
46					"flag": "dPwWtRNjPgOGlqQp3HV4grvOnyBC4td74JsAZtkI.png",
47					"created_at": "2022-11-16T02:56:50.000000Z",
48					"updated_at": "2022-11-16T02:56:50.000000Z"
49				}
50			}
51		}

There was a prediction_closes_at time for each fixture of the match so I knew from the pattern of the matches so far that If neither of the team’s scored before the prediction closes (which was approx 70mins into the game) I would get points. And for extra monitoring, I also made a telegram bot to send me a notification every time the prediction bot made a prediction.

telgram bot

So I tested and made the bot in like few hours & I initially made it to predict only the last 2 mins before the prediction closes but that had a major flaw when sometimes when the cron job failed. I instead then changed the bot to predict the current score every 2 mins until the prediction close time. I got a lot of points and even somehow I was able to reach the leaderboard!

Leader board

I think if the bot was active from the beginning of world-cup I would have had a chance to win some goodies. But it was just unpredictable in the knock-out matches & most matches after that. But it was a really fun experiment regardless.

Below is the link to the GitHub repo of the project. Don’t mind the messy code I was in a rush.

Cheers

Github