Howdy, friends!
A friend of mine asked me about creating a project that takes snapshots of data from a website called Nitro Type. I have messed around with various APIs of different websites before, but all of those have their APIs documented.
Here is the data I want to collect: https://www.nitrotype.com/api/v2/teams/S0RC
I wrote a Python script to collect data from that, but I am being rejected by the NT servers. I’ve seen some Github repos that provide some unofficial NitroType APIs, but what exactly does that mean? How could I write my own unofficial NitroType API?
Here is some basic Python code to access the data from the API link I gave above:
import requests
import json
# Define the URL for the NitroType API
url = "https://www.nitrotype.com/api/v2/teams/S0RC"
# Send a GET request to the API
response = requests.get(url)
# Check if the request was successful
if response.status_code == 200:
# Parse the JSON response
data = response.json()
# Extract the members' data
members = data["members"]
# Create a list to store the member data
member_data = []
# Iterate over each member and extract the desired information
for member in members:
username = member["username"]
user_id = member["id"]
wpm = member["stats"]["wpm"]
accuracy = member["stats"]["accuracy"]
races_played = member["stats"]["racesPlayed"]
# Create a dictionary for the member's data
member_info = {
"Username": username,
"ID": user_id,
"WPM": wpm,
"Accuracy": accuracy,
"Races Played": races_played
}
# Add the member's data to the list
member_data.append(member_info)
# Convert the member data to JSON format
json_data = json.dumps(member_data, indent=4)
print("JSON data:")
print(json_data)
else:
print("Failed to retrieve data. Status code:", response.status_code)