Racers-API - a game where you have to go around racing with your car, earning money

Overview

Racers-API

About

Racers API is a game where you have to go around racing with your car, earning money. With that money you can buy cars and progress through the game! You have to combine your coding skills and knowledge to start and finish. Making HTTP requests to the API and getting a response is what you need to learn. You can play Racers API with any language that supports HTTP requests. Learn more in the Documentation section

Documentation

Python

Checking the status of the server:

import requests

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

If it outputs "Racers API is ready to play!" then the server is available. Otherwise, you might get an error. If that happens and all you code is correct, it means the server is likely down.

Getting a key and starting off:

import requests
import json

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

#Getting an API key
username = "hello"
startURL = "https://racersapi.billybob456.repl.co/start/" + username

x = requests.get(startURL)
x = x.content
x = json.loads(x)
key = x["key"]
print(x["message"])

Getting your account information:

import requests
import json

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

#Getting an API key
username = "hello"
startURL = "https://racersapi.billybob456.repl.co/start/" + username

x = requests.get(startURL)
x = x.content
x = json.loads(x)
key = x["key"]
print(x["message"])

account = requests.get("https://racersapi.billybob456.repl.co/account/" + key).content.decode("utf-8")
print(account)

Getting your current car:

import requests
import json
import ast

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

#Getting an API key
username = "hello"
startURL = "https://racersapi.billybob456.repl.co/start/" + username

x = requests.get(startURL)
x = x.content
x = json.loads(x)
key = x["key"]
print(x["message"])

account = ast.literal_eval(requests.get("https://racersapi.billybob456.repl.co/account/" + key).content.decode("utf-8"))
print(account)

currentCar = account["car"]
print(currentCar)

Getting the available races:

...
availableRaces = requests.get("https://racersapi.billybob456.repl.co/available-races/" + key).content.decode("utf-8")
print(availableRaces)

Selecting the race with best difficult:payout ratio:

...
#Selecting the best race with difficulty:payout ratio
litEvalList = ast.literal_eval(availableRaces)
length = len(litEvalList)
for race in litEvalList:
	avgSpeed = race["average top speed"]
	if avgSpeed == currentCar["top speed"]:
		raceNum = litEvalList.index(race)
raceKey = json.loads(availableRaces)[raceNum]["key"]

Racing the selected race:

...
#Racing the selected race
raceURL = "https://racersapi.billybob456.repl.co/race/" + key + "/" + raceKey
raceResults = requests.get(raceURL).content.decode('utf-8')
raceKey = ""
raceResults = ast.literal_eval(raceResults)
key = raceResults["key"] #new key
print(raceResults["message"])

Full script:

import requests
import json
import ast

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

#Getting an API key
username = "hello"
startURL = "https://racersapi.billybob456.repl.co/start/" + username

x = requests.get(startURL)
x = x.content
x = json.loads(x)
key = x["key"]
print(x["message"])

#Getting account information
account = ast.literal_eval(requests.get("https://racersapi.billybob456.repl.co/account/" + key).content.decode("utf-8"))
print(account)

#Getting you current car
currentCar = account["car"]
print(currentCar)

#Getting available races
availableRaces = requests.get("https://racersapi.billybob456.repl.co/available-races/" + key).content.decode("utf-8")
print(availableRaces)

#Selecting the best race with difficulty:payout ratio
litEvalList = ast.literal_eval(availableRaces)
length = len(litEvalList)
for race in litEvalList:
	avgSpeed = race["average top speed"]
	if avgSpeed == currentCar["top speed"]:
		raceNum = litEvalList.index(race)
raceKey = json.loads(availableRaces)[raceNum]["key"]

#Racing the selected race
raceURL = "https://racersapi.billybob456.repl.co/race/" + key + "/" + raceKey
raceResults = requests.get(raceURL).content.decode('utf-8')
raceKey = ""
raceResults = ast.literal_eval(raceResults)
key = raceResults["key"]
print(raceResults["message"])

Well done! You've successfully gone through the basics of Racers API and completed your first race! Below are your next steps.

After getting you new key, you want to save it somewhere! Here's a modified script of the full script that will allow you to continue your game with the new key:

import requests
import json
import ast

#Checking the status of the server
statusURL = "https://racersapi.billybob456.repl.co/status"
status = requests.get(statusURL)
status = status.content.decode("utf-8")
print(status)
if status == "Racers API is ready to play!":
	pass
else:
	print("Racers API is unavailable to play at the moment")
	exit()

key = "YOUR KEY HERE!" #put your key in there!

#Getting account information
account = ast.literal_eval(requests.get("https://racersapi.billybob456.repl.co/account/" + key).content.decode("utf-8"))
print(account)

#Getting you current car
currentCar = account["car"]
print(currentCar)

#Getting available races
availableRaces = requests.get("https://racersapi.billybob456.repl.co/available-races/" + key).content.decode("utf-8")
print(availableRaces)

#Selecting the best race with difficulty:payout ratio
litEvalList = ast.literal_eval(availableRaces)
length = len(litEvalList)
for race in litEvalList:
	avgSpeed = race["average top speed"]
	if avgSpeed == currentCar["top speed"]:
		raceNum = litEvalList.index(race)
raceKey = json.loads(availableRaces)[raceNum]["key"]

#Racing the selected race
raceURL = "https://racersapi.billybob456.repl.co/race/" + key + "/" + raceKey
raceResults = requests.get(raceURL).content.decode('utf-8')
raceKey = ""
raceResults = ast.literal_eval(raceResults)
key = raceResults["key"]
print(raceResults["message"])

More documentation coming out soon including how to buy new cars and mod the game to add your own cars!

Console 2D GameEngine {C2DGE} [0.1.0]

Console 2D GameEngine {C2DGE} [0.1.0] By Grosse pastèque#6705 The Project's Goal : This projects was just a challenge so if you have bad reviews, it's

Big watermelon 1 Nov 06, 2021
Automatic game data translator for RPGMaker-MV

RPGMaker-MV Translator 🕹️ 🎮 Use AI to translate all the dialogs and texts of your RPGMaker automatically. 👊 You worked hard to make your game, now

Davide Liu 11 Dec 26, 2022
Dontdie-minecraft - A python program that causes your computer to bluescreen whenever you die in Minecraft

Don't Die - A Python Program A python program that causes your computer to blues

3 Apr 19, 2022
Pygame Raycaster made by me.

Pygame Raycaster made by me.

Sable 0 Jan 10, 2022
Lint game data metafiles against GTA5.xsd for Rockstar's game engine (RAGE)

rage-lint Lint RAGE (only GTA5 at the moment) meta/XML files for validity based off of the GTA5.xsd generated from game code. This script accepts a se

GoatGeek 11 Sep 18, 2022
Create a Hangman Game using Python and all techniques of Python.

Hangman Game Created by Fernando Callasaca Game rules: Choose a word and if you guess it will appear completed. In case it is not the word then the ma

Fernando Callasaca 3 Nov 01, 2021
A fully automated system that transforms Twitch clips into gaming compilations

A fully automated system that transforms Twitch clips into gaming compilations Authors: Christian C., Moritz M., Luca S. Related Projects: Neural Netw

215 Dec 27, 2022
Flappy Bird Game using Pygame in Python

Flappy Bird Game using Pygame in Python Demo Pages Hello dear, hope you are very well! I created Flappy Bird Game using Pygame ( Pygame is a cross-pla

Datt Panchal 3 Feb 05, 2022
BUG OUTBREAK is a game of adventure and shooting.

BUG OUTBREAK BUG OUTBREAK is a game of adventure and shooting. I am building the game for Github Game Off 2021. This game has 5 levels. You have to co

Shreejan Dolai 3 Nov 11, 2022
A Simple Scissor Paper Rock Game On Python Using Pygame.

Scissor Paper Stone Game Using Pygame This is a simple GUI based game made on pygame python. Installation Run code on your machine: git clone https:

Dipin Adhikari 0 Mar 21, 2022
16-bit PvP platform minigame made for a final high-school project

16-bit PvP platform minigame made for a final high-school project

Flavien 1 Feb 10, 2022
The Sinclair ZX Spectrum BASIC compiler!

ZX BASIC Copyleft (K) 2008, Jose Rodriguez-Rosa (a.k.a. Boriel) http://www.boriel.com All files in this project are covered under the GPLv3 LICENSE ex

Jose Rodriguez 143 Dec 13, 2022
Flappy Bird hack using Deep Reinforcement Learning (Deep Q-learning).

Using Deep Q-Network to Learn How To Play Flappy Bird 7 mins version: DQN for flappy bird Overview This project follows the description of the Deep Q

Yen-Chen Lin 6.4k Dec 30, 2022
A program to read, edit, and write save files for the game Railroads! Online

RROSE - v0.3.6 This program is intended to be used as an external tool to Railroads Online server hosts. It will read save files, allow to modify entr

17 Dec 09, 2022
A Cataclysm: Dark Days Ahead launcher with additional features

CDDA Game Launcher A Cataclysm: Dark Days Ahead launcher with additional features. Download here. Implemented features Launching the game Detecting th

Rémy Roy 402 Jan 02, 2023
A "guess the number" game on a GUI interface using Tkinter library🙂

A "guess the number" game on a GUI interface using Tkinter library🙂

Arsalan 2 Feb 01, 2022
PyGame-Tutorial - Refrence for building games in pygame

PyGame-Tutorial How to build games using the python library PyGame End result Ho

St. Mark's Computer Science Club 2 Jan 09, 2022
A python script to solve Wordle puzzles

Wordle solver A python script to solve Wordle puzzles.

Felix Weinberger 1 Feb 12, 2022
EL JUEGO DEL GUSANITO

EL JUEGO DEL GUSANITO El juego consiste en una línea que no para de moverse, el usuario lo controla con las flechas de: → derecha ← izquierda ↑ arriba

Valeria Saidid Miranda Ibarra 0 Dec 19, 2021
Open source Board Games Like Tic Tac Toe, Connect 4, Ludo, Snakes and Ladder etc...

Board-Games What to do... Add Board games like Tic Tac Toe, Connect 4, Ludo, Snakes and Ladder etc... How to do... Fork the repo Clone the repo git cl

Bit By Bit 1 Oct 10, 2022