It looks great, well documented, REST based, intuitive. There’s also some useful tools around the API like a few helper methods that return the data required for making use of their advertised capabilities and a useful ‘health status‘ site.
So utilizing the Mule Devkit the possibility of combining our favorite integration engine (i.e. Mule) with a little sporting statistics was very enticing.
Now before we get started let’s look at what do we have here:
- ESPN sports data, the innovation possibilities here are almost endless. Available categories include:
- Sports headlines
- Score & Game schedules
- Team data
- Athlete data
- Research notes (player stats & information)
- & much, much, more.
- Mule ESB the worlds most popular open source integration platform,
Using Mule it would be reasonably straight forward to invoke the ESPN API directly using an http endpoint, or a combination of custom components. However if I want to package all the methods exposed by this API and make it easily accessible to all of my developers the Mule DevKit is the best option.
Using the DevKit I can create a reusable Mule Connector that abstracts all of the low level implementation details related to interacting with the ESPN API that include, REST specifics (GET, PUT, POST, etc…), security, session management, and the configuration process. In addition to that once complete I can easily share this component with all developers in my organization using the Mule Studio eclipse update site capability, or alternatively with the entire Mule community on the Mule Extensions site (note: the artist previously known as the Mule Forge).
So how do we get started?
Firstly the recent release of the Mule 3.3.2 DevKit has made this process even easier. It includes a new annotation based approach to accessing API’s, which means you don’t even really need to know much about REST in order to create a Mule extension. For the university students out there the Devkit abstracts all the underlying details associated with Spring Namespace handlers that you would need to understand to create a Mule connector, and generates all of the required boiler plate code for testing and integrating your component with the Mule ESB engine. This also include ‘auto-generated’ documentation, which is a significant benefit to most developers for whom technical documentation is not their foremost passion. Here what I did:
Firstly using the DevKit maven archetype I was able to create my Mule ESPN API connector project and generate all the boiler plate code for interfacing between Mule ESB and the underlying Spring namespace handlers that make this all possible. There is a great write-up on how to do this for the first time here (http://www.mulesoft.org/documentation/display/DEVKIT/Your+First+Cloud+Connector).
Next I registered with the ESPN API to obtain a developer key to their API, which was required for testing (http://developer.espn.com/overview). In the real connector this is API Key actually becomes a configurable component, which I can externalize and manage through a property file within Mule.
Then start coding against the API. The ESPN team have made this as simple as possible by providing lots of sample requests on their site, with detailed descriptions of what each parameter does. A good way to get started is to invoke the sample requests using curl and your api key, this will iron out any connectivity or authorization issues that you may encounter before you get started writing code.
The REST calls within the devkit code are very easy to configure using the new annotation approach, here’s an example:
An interesting thing to note here is that beyond creating Mule extensions such as the ESPN connector, the Devkit can also be used to create transformers or customer extensions (including validators) to the Mule ESB as John D’Emic illustrates in this post (http://blogs.mulesoft.com/implementing-custom-validation-with-devkit/).
And finally here’s the completed Mule ESPN API connector, download Mule 3.3.2 (http://www.mulesoft.com/mule-esb-enterprise) today and give it a try
To access the ESPN Connector from Mule Studio complete the following steps:
1. Refer to documentation – Installing additional connectors:http://www.mulesoft.org/documentation/display/current/Additional+Cloud+Connectors
2. Add the Mule Beta connectors Eclipse Update site (http://repository.mulesoft.org/connectors/beta/1):
- MuleStudio > Help > Install New Software…
- Click “Add” and enter, Name=Mule Beta Connectors,Location=http://repository.mulesoft.org/connectors/beta/1
3. Install Espn Connector from ‘Community’ (Beta):
- Expand the ‘Community’ drop down menu
- Select “Mule ESPN Cloud Connector Mule Studio Extension”, then Click ‘Next’
- Review and Accept license details, then Click ‘Finish’
4. Your newly installed ESPN Connector should be available from the ‘Cloud Connectors’ palette
- You may need to restart Mule Studio before the connector is displayed.
For those who are interested in what it takes to create your own Mule extension the complete source code for the ESPN Connector that I created using the Mule Devkit is available here: (https://github.com/mulesoft/espn-connector)!!