Skip to content

Instantly share code, notes, and snippets.

@jmelancon
Created March 30, 2022 04:53
Show Gist options
  • Save jmelancon/98017522fc9f53694ee6b22fd729f817 to your computer and use it in GitHub Desktop.
Save jmelancon/98017522fc9f53694ee6b22fd729f817 to your computer and use it in GitHub Desktop.
# joseph melancon
# 4198 RoboCats
# 2022
import json
import requests
from requests.structures import CaseInsensitiveDict
def main():
url = "https://frc-api.firstinspires.org/v3.0/%%YEAR%%/schedule/%%EVENTCODE%%?tournamentLevel=qual"
headers = CaseInsensitiveDict()
headers["Accept"] = "application/json"
data = json.loads(requests.get(url, headers=headers, auth=("%%USERNAME%%","%%APIKEY%%")).text)
matcharray = []
for qualdata in data["Schedule"]:
red1 = qualdata["teams"][0]["teamNumber"]
red2 = qualdata["teams"][1]["teamNumber"]
red3 = qualdata["teams"][2]["teamNumber"]
blue1 = qualdata["teams"][3]["teamNumber"]
blue2 = qualdata["teams"][4]["teamNumber"]
blue3 = qualdata["teams"][5]["teamNumber"]
teamsList = [red1, red2, red3, blue1, blue2, blue3]
matcharray.append(teamsList)
print(matcharray)
if __name__ == "__main__":
main()
@jmelancon
Copy link
Author

This script will download qualification match itineraries from FRC's API, then, put the data together into an array. This is intended for use with https://github.com/jmelancon/MeanScout_4198/. Remember to replace anything like "%%YEAR%%", "%%EVENTCODE%%", or otherwise with the proper data!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment