Team List RSS?

I’m looking to import a list of teams so I can populate this season’s scouting database.

Does anyone know where I can get access to a list like that, in a format that lends itself to import?

I tried perusing https://my.usfirst.org/frc/tims, but it’s currently broken with Error -9995. I also visited thebluealliance.com, but didn’t see anything obvious there. Lastly, I did search the forum, but couldn’t find anything relevant in a timely manner.

Any suggestions for a team list, and/or an event list, would be appreciated. Feel free to contact me via pm or via email: jason dot buxton @t gmail DOT com.

Check out The FIRST Alliance API
http://thefirstalliance.com/apidoc.php

Thanks!

Either I did it wrong, or something’s amiss:

http://www.thefirstalliance.org/api/api.xml.php?action=list-teams

This returns an error, although I think the complete XML document is included in the source…

[EDIT]:

Ah, it looks like some teams’ names are unparseable in XML:

<br />
<b>Warning</b>: SimpleXMLElement::addChild() <a href=‘simplexmlelement.addchild’>simplexmlelement.addchild</a>]: unterminated entity reference Gadget Engineering) in <b>/homepages/26/d409590785/htdocs/first-api/first_scraper_web/api/api.xml.php</b> on line <b>36</b><br />
<br />
<b>Warning</b>: SimpleXMLElement::addChild() <a href=‘simplexmlelement.addchild’>simplexmlelement.addchild</a>]: unterminated entity reference Irish Bots in <b>/homepages/26/d409590785/htdocs/first-api/first_scraper_web/api/api.xml.php</b> on line <b>36</b><br />
<br />
<b>Warning</b>: SimpleXMLElement::addChild() <a href=‘simplexmlelement.addchild’>simplexmlelement.addchild</a>]: unterminated entity reference Machines (M&Ms) in <b>/homepages/26/d409590785/htdocs/first-api/first_scraper_web/api/api.xml.php</b> on line <b>36</b><br />
<br />
<b>Warning</b>: SimpleXMLElement::addChild() <a href=‘simplexmlelement.addchild’>simplexmlelement.addchild</a>]: unterminated entity reference Bolts of Fury in <b>/homepages/26/d409590785/htdocs/first-api/first_scraper_web/api/api.xml.php</b> on line <b>36</b><br />
<br />
<b>Warning</b>: SimpleXMLElement::addChild() <a href=‘simplexmlelement.addchild’>simplexmlelement.addchild</a>]: unterminated entity reference Bots in <b>/homepages/26/d409590785/htdocs/first-api/first_scraper_web/api/api.xml.php</b> on line <b>36</b><br />
<br />
<b>Warning</b>: SimpleXMLElement::addChild() <a href=‘simplexmlelement.addchild’>simplexmlelement.addchild</a>]: unterminated entity reference Wayne County Robotics in <b>/homepages/26/d409590785/htdocs/first-api/first_scraper_web/api/api.xml.php</b> on line <b>36</b><br />
<br />
<b>Warning</b>: SimpleXMLElement::addChild() <a href=‘simplexmlelement.addchild’>simplexmlelement.addchild</a>]: unterminated entity reference Colts in <b>/homepages/26/d409590785/htdocs/first-api/first_scraper_web/api/api.xml.php</b> on line <b>36</b><br />

I’ll work with the JSON syntax!

I generally find JSON data easier to work with.
If you’re using Java I have a simple class to work with the FIRST Alliance APIs.

If you use this and don’t use AppEngine, then you need to replace the JSON imports with JSON classes found elsewhere.

package org.team3309.scout;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;

import com.google.appengine.labs.repackaged.org.json.JSONArray;
import com.google.appengine.labs.repackaged.org.json.JSONException;
import com.google.appengine.labs.repackaged.org.json.JSONObject;

public class FirstAlliance {

	private static final String API = "http://www.thefirstalliance.org/api/api.json.php?action=";

	public static Event] getEvents(String teamNumber) {
		Event] competitions = new Event[0];
		String url = API + "team-events&team-number=3309";
		JSONArray events = getArray(url);
		competitions = new Event[events.length()];
		try {
			for (int i = 0; i < events.length(); i++) {
				JSONObject event = events.getJSONObject(i);
				competitions* = new Event(event);
			}
		} catch (JSONException ex) {
			ex.printStackTrace();
		}
		return competitions;
	}
	
	public static Event getEventById(int id){
		String url = API+ "event-details&event-id="+id;
		JSONObject json = getJson(url);
		return new Event(json);
	}
	
	private static JSONArray getArray(String url) {
		try {
			HttpURLConnection c = (HttpURLConnection) new URL(url)
					.openConnection();
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					c.getInputStream()));
			String line;
			String input = "";
			while ((line = reader.readLine()) != null)
				input += line;
			JSONObject json = new JSONObject(input);
			return json.getJSONArray("data");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return null;
	}
	
	private static JSONObject getJson(String url){
		try {
			HttpURLConnection c = (HttpURLConnection) new URL(url)
					.openConnection();
			BufferedReader reader = new BufferedReader(new InputStreamReader(
					c.getInputStream()));
			String line;
			String input = "";
			while ((line = reader.readLine()) != null)
				input += line;
			JSONObject json = new JSONObject(input);
			return json.getJSONObject("data");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return null;
	}

	public static class Event{
		
		private String name;
		private int id;
		private JSONArray rankingsJson;
		private ArrayList<Ranking> rankings;
		
		private Event(JSONObject json){
			this.name = json.optString("name");
			this.id = json.optInt("id");
			this.rankingsJson = json.optJSONArray("rankings");
		}
		public String getName(){
			return name;
		}
		public int getId(){
			return id;
		}
		public ArrayList<Ranking> getRankings(){
			if(rankings != null)
				return rankings;
			ArrayList<Ranking> list = new ArrayList<Ranking>();
			for(int i=0; i<rankingsJson.length(); i++){
				JSONObject json = rankingsJson.optJSONObject(i);
				list.add(new Ranking(json.optString("Team"), json.optInt("Rank"), json.optString("Record (W-L-T)")));
			}
			return list;
		}
		
		public String toString(){
			return name;
		}
	}
	
	public static class Ranking{
		
		private String team, record;
		private int ranking;
		
		private Ranking(String team, int ranking, String record){
			this.team = team;
			this.ranking = ranking;
			this.record = record;
		}
		
		public String getRecord(){
			return record;
		}
		
		public int getWins(){
			return Integer.parseInt(record.substring(0, record.indexOf("-")));
		}
		
		public int getLosses(){
			return Integer.parseInt(record.substring(record.indexOf("-")+1, record.indexOf("-", record.indexOf("-")+1)));
		}
		
		public int getTies(){
			return Integer.parseInt(record.substring(record.lastIndexOf("-")+1));
		}
		
		public String getTeam(){
			return team;
		}
		
		public int getRank(){
			return ranking;
		}
	}
}

I’m exploring the rest of the API, and I was wondering if you had a guide to all of the acronyms used in the ‘rankings’?

Can you give me an example so that I can try to help you?

Sure:

{“Rank”:“2”,“DQ”:“0”,“CP”:“0”,“QS”:“18.00”,“BP”:“210.00”,“TP”:“200.00”,“Record (W-L-T)”:“9-1-0”,“HP”:“214.00”,“Team”:“138”,“Played”:“10”}

DQ? CP? QS? BP? TP? HP?

Here are the tab separated lists from FIRST

Teams
https://my.usfirst.org/frc/scoring/index.lasso?page=teamlist

Events
https://my.usfirst.org/frc/scoring/index.lasso?page=eventlist