Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   The Blue Alliance (http://www.chiefdelphi.com/forums/forumdisplay.php?f=174)
-   -   [TBA]: API Client Development (http://www.chiefdelphi.com/forums/showthread.php?t=65055)

Greg Marra 24-02-2008 23:26

[TBA]: API Client Development
 
TBA currently offers an API client in PHP that can be found here.

I know Eric Haskins has written a .NET port that can be found here for now, and Team 1515 is writing a Rails port. I think myself or Chris Jelly will be working with these guys to make their ports available from the TBA site.

Has anyone else written a port of the Client Library? What issues have you had porting it?

CapnKernel 24-02-2008 23:38

Re: API Client Development
 
1 Attachment(s)
I just finished a Ruby (on Rails) client library.

Feel free to use it. :)
Have any questions, comments, bug fixes, complaints, or just want to talk to someone who knows Ruby, contact me via:

AIM/Skype: talk2kern
MSN/Email: talk2kern@gmail.com

EHaskins 25-02-2008 10:54

Re: API Client Development
 
1 Attachment(s)
I attached a copy of my .net client. Currently the only documentation is the code, but if there is any interest I can finish better documentation.

It requires .net 3.5, and Visual Basic 2008 Express or Visual Studio 2008 or greater.

Currently there are two projects, a class library with the client, and a console app which can be used to query the API. The readme file has instructions how to set your API key in the config file.

I have put the code under the Microsft Public License, so you are free to modify or redistribute it how ever you want.

If anyone has questions, comments, bug reports, ect., please contact me. My Skype, MSN, and e-mail, are in my profile, you can contact me using any of those methods.

EHaskins 25-02-2008 22:14

Re: API Client Development
 
1 Attachment(s)
I attached the compiled version of the code I posted above.

Greg Marra 25-02-2008 22:26

Re: API Client Development
 
I've updated the documentation and files available for download at: http://www.thebluealliance.net/tbatv/api/

I'll write a pretty page to wrap around it at some point.

EHaskins 28-02-2008 13:17

Re: API Client Development
 
2 Attachment(s)
Here is v1.1 of my library.

There is only one bug fix.
1. When loading matches, some of the matches at the 2007 Florida regional are missing team numbers, and the parser would crash. That has been resolved.

CapnKernel 28-02-2008 20:10

Re: API Client Development
 
1 Attachment(s)
Also found a bug in my Ruby code when I actually used it in practice for my application.

This'll make the code more Ruby-like and return false if there are no results found but an error does not occur.

Happy coding!

Greg Marra 28-02-2008 20:48

Re: API Client Development
 
Both updated libraries have been added to http://www.thebluealliance.net/tbatv/api/.

Thanks guys!

EHaskins 28-02-2008 22:36

Re: API Client Development
 
Would it be useful to create a SourceForge, CodePlex, GoogleCode, ect, site where we could mantain a record of any client libraries people develop?

Just a thought.

Greg Marra 29-02-2008 00:30

Re: API Client Development
 
I'm not sure we're at that level of complexity yet, but it is an idea worth keeping in mind if the number starts to get big or there is much need to change them. :)

Greg McCoy 07-03-2008 02:18

Re: API Client Development
 
1 Attachment(s)
This is very cool stuff...I'm using the TBA API now for the Boilermaker Regional website, and I hope to expand our usage once I have some time to explore all of the possibilities...

I'll try and pay it forward with a Python connector...I've only had my API key for 12 hours or so, so I haven't tested this extensively but it should work fairly well. :D If you notice any bugs or anything that could be improved, let me know!


Thanks!

Greg McCoy 09-03-2008 03:14

Re: API Client Development
 
1 Attachment(s)
Here's an update to my Python connector...this adds a function to turn the results into plain ol' Python dictionaries and lists, so it's really easy to use, no XML module knowledge required.

proegssilb 09-03-2008 13:45

Re: API Client Development
 
Huh, great minds think alike. I've also been working on using TBA in python. Oh well. We'll see where that goes; I'm done with the get<items>() functions, but I want to build on that so it is Object-Oriented.

Nibbles 25-03-2008 17:13

Re: [TBA]: API Client Development
 
Quote:

Originally Posted by Greg Marra (Post 706671)
TBA currently offers an API client in PHP that can be found here.

...

Has anyone else written a port of the Client Library? What issues have you had porting it?

I noticed other threads with people having problems. PHP5 has this great new thing called Exceptions. If there is an error, it will kill the execution of the script, unless the programmer has a method of catching and handling the exception.
The official PHP client is serverely lacking in error checking, for instance, if the API server returns a blank XML (XHTML, say) document, then no error will pop up.

I'll keep it simple, my edits are public domain. I have not tested this, but it should work.
Code:

function tba_send_request($method, $arguments=array()){
  $api_key = ""; //replace with your API key
  $api_url = "http://thebluealliance.net/tbatv/api.php"; //this should not change
  // prepend the default array elements
  $arguments = array('version'=>1, 'api_key'=>$api_key,'method'=>$method) + $arguments;
  $file = $api_url.'?'.http_build_query($arguments);
  $xml = simplexml_load_file($file);
  // check for a broken connection, bad XML, etc
  if($xml===false) throw new Exception("Bad XML returned getting file $file");
  // check for errors thrown by the server
  if (count($xml->error)){
    throw new Exception("Error generated by API server: ".(string)$xml->error->text, (int)$xml->error->code);
  }else{
    return $xml;
  }
}

While you could put these functions into a class, and have the API key be a property of the object, I would not recommend it (at least for PHP), there is no benefit to using object-oriented programming here (since the most objects you will ever need is one).

EHaskins 28-03-2008 21:15

Re: [TBA]: API Client Development
 
2 Attachment(s)
I've been experimenting with the API, and for compatibility reasons I've created a .net 2.0 port of my .net 3.5 client. I haven't done any performance comparisions, so don't ask about that.

The demo console app also has some small improvments, but nothing too major.

EDIT: Added license and readme to source file, and added compiled version.


All times are GMT -5. The time now is 19:46.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi