FRC Blog - Event Data Improvements – Don’t be a Dinosaur!

FIRST has shown that they like community initiatives (such as FIRST Updates Now featured) so long as it is clear they are not official. As an avid TBA user, I can say that I hope it never goes away. I also agree though that it is a very good thing that FIRST is improving their own tools. I’d rather have two websites that I can turn to than one.

It’s like if Bing decided that they wanted to be good. We all know and love Google - but it wouldn’t hurt if there was a second, good quality search engine.

Also, in a way FIRST is supporting TBA - very few people/apps use the FIRST API. They know that TBA uses the API so when they improve the API, they are really improving TBA, as well. Even most of the other, lesser know third party apps are using the TBA API to collect data rather than from FIRST directly (mainly due to its ease of use and getting keys…).

So I am glad that FIRST is improving their website trying to become less like Bing and more like Google. But I’m also glad Google is here and functioning bigger and better than ever.

Having used both API’s, I can tell you that they were both easy to use (heck, using them is practically identical, depending on what data you’re going after), and it was straightforward to get keys (although TBA was quicker than FIRST).

I would guess the preference for TBA API’s is due to its longevity more than anything else. The FIRST API has only been around for a couple of years. Before that, TBA had scripts that parsed the FIRST webpages and pulled out needed info. Then TBA introduced their API, and everyone started using that instead of trying to duplicate the parsing scripts. And then FIRST released their API. A solution that was originally written for the TBA API is easier to remain on the same API than switching.

It’s also that FIRST’s API has tended to change. I’ve tried using FIRST’s API only to come back the next year to it being broken. TBA? I have faith that my scripts will work for a few years.

I have also used both APIs. Here are my main issues - none of them are major but they are what shapes my opinion:

  • My first issue with the official API is that it was a slight ordeal to get a key. I couldn’t just go ahead and start.
  • Another concern of mine is that I do a lot of work in spreadsheets and the only way I can authenticate is with a URL parameter - something I cannot do with the FIRST API.
  • The documentation of the TBA API is less wonky so it is easier for me to follow.
  • There are lots of people I can turn to with questions about the TBA API and get a fast response. FIRST is responsive but it is less immediate in my experience.

Again, I don’t think that these things are deal breakers for everyone, but they are for me.

Well, RIP lasso pages… They get redirected as of this morning.

No way to count events, no way to see City/State info in a list. Thank God we have TBA’s API.

/mourn

I wouldn’t say no way. The FIRST FRC API is quite simple to use.

$APICredential = Get-Credential -Message "Enter you API Authorization key"
$targetDirectory = "."
$Year = "2018"

#Get the events and save them to a csv file that can be imported to Excel or other tool
$FRCevents = Invoke-RestMethod -Uri https://frc-api.firstinspires.org/v2.0/$Year/events -Method Get -Credential $APICredential

#Save Regional events to a CSV file
$FRCevents.Events | select * | where {$_.type -eq "Regional"} | sort dateStart,name | ConvertTo-Csv -NoTypeInformation -delimiter "`t"  > $targetDirectory\Regionals$Year.csv

#Save District events to a CSV file
$FRCevents.Events | select * | where {$_.type -eq "DistrictEvent"} | sort type,districtCode,dateStart,name | ConvertTo-Csv -NoTypeInformation -delimiter "`t"  > $targetDirectory\Districts$Year.csv

#construct a text file with district and regionl events broken down by district and date
$targetFile = $targetDirectory + "\events2018.txt"
$sortedRegionals = {$FRCevents.Events | select * | where {$_.type -eq "Regional"}| sort dateStart,name }.invoke()
$lastDate = ""
"2018 Regionals" > $targetFile
Foreach ($event in $sortedRegionals)
{ 
    if ($event.dateStart -ne $lastDate)
    {
        $string = "Starting Date " + $event.dateStart.Substring(5,2) + "/" + $event.dateStart.Substring(8,2)
        Add-Content $targetFile ""
        Add-Content $targetFile $string
       
        $lastDate = $event.dateStart
    }
    $string =  $event.name + ", " + $event.address + ", " + $event.city + ", " + $event.stateprov + ", " + $event.country
    Add-Content $targetFile $string
}

$sortedDistricts = {$FRCevents.Events | select * | where {$_.type -eq "DistrictEvent"}| sort districtCode,dateStart,name }.invoke()
$lastDistrict = ""
$lastDate = ""
Add-Content $targetFile ""
Add-Content $targetFile "District Events 2018"
ForEach ($event in $sortedDistricts)
{
    if ($event.districtCode -ne $lastDistrict)
    {
        Add-Content $targetFile ""
        Add-Content $targetFile $event.districtCode
        $lastDistrict = $event.districtCode
        $lastDate = ""
    }
    if ($event.dateStart -ne $lastDate)
    {
        $string = "Starting Date " + $event.dateStart.Substring(5,2) + "/" + $event.dateStart.Substring(8,2)
        Add-Content $targetFile ""
        Add-Content $targetFile $string
        $lastDate = $event.dateStart
    }
    $string =  $event.name + ", " + $event.city + ", " + $event.stateprov + ", " + $event.country
    Add-Content $targetFile $string
}

```<br><br><a class='attachment' href='/uploads/default/original/3X/a/d/ad15a0ac8ece104145c1053017be9d095b64d5c9.csv'>Districts2018.csv</a> (39.5 KB)<br><a class='attachment' href='/uploads/default/original/3X/1/e/1e5d115b0f4b6f052ef192b3ee2edfe0a1d88677.csv'>Regionals2018.csv</a> (23.7 KB)<br><a class='attachment' href='/uploads/default/original/3X/6/9/69b081daeeed511fd623004cbf2d56c270b02371.txt'>events2018.txt</a> (18.8 KB)<br>

I see your 56 lines of code and raise you 1:


wget "https://my.usfirst.org/myarea/index.lasso?event_type=FRC&year=2018"

Nevermind with the token requirements you can’t just start using the API… AND you have to remember to log into the FRC website every 6 mos. Still just easier to use the TBA API… Not that we should have to use an API to get this information in the first place.

Actually, it’s just the first 5 lines that are needed, most of that script is dedicated to building the text file that lists regionals by week and event name, then lists districts by district name, week and event name. But here you go. Three lines that get every event and dump it into a CSV that you can open in Excel.

$APICredential = Get-Credential -Message "Enter you API Authorization key"
$FRCevents = Invoke-RestMethod -Uri https://frc-api.firstinspires.org/v2.0/2018/events -Method Get -Credential $APICredential
$FRCevents.Events | select * | ConvertTo-Csv -NoTypeInformation -delimiter "`t"  &gt; Events2018.csv

You still need an API key, but that’s an email.

I get why changes have to be made to have a more robust system, but I will definitely miss the lasso pages. There was something incredibly simple about just typing frclinks.com/t/ON-Canada into my browser and being able to pull up a current list of registered teams in Ontario. With browser shortcuts I had it down to “frc /t/ON-Canada”. The lasso pages will be missed.

Yeah, it was super unintuitive for virtually everyone, but the power users that could remember event codes and all of the FRCL shortcuts, it was incredible.

It would be cool to see the functions fully replicated with The Blue Alliance.

What specifically would you like to see TBA implement? (it’s been a long time since I’ve looked at the lasso pages and can’t remember what info they show)

It’d be sweet if TBA would extend the function of the (already awesome) search nearby feature to let me search just by state or district, instead of in a radius around a location.

http://frclinks.frclinks.com/ gives a good description of what these pages used to show.

Using the event code, or a team number, you can just type in the textbox on the top center of the homepage of the frc-events website. It’ll jump straight to the team or event. The direct link to an event is just frc-events.firstinspires.org/YEAR/CODE. For a team it would be /YEAR/t/TEAM

Unpublicized feature that’s probably really buggy. https://www.thebluealliance.com/events?state_prov=CA

Goal is to make it better someday…

Yeah, you’re right. I should already know that considering that’s how I kept track of district points last year since TBA had out of bounds teams in the rankings.