USA TODAY client libraries for Java
Java client libraries created with Mashery I/O Wraps, a semi-automated native language SDK generator.
USA TODAY offers content APIs that allow developers to access their resources, such as news articles, book reviews, best seller lists (books), census data, movie reviews, music reviews and much more. Head over to developer.usatoday.com to learn more. You can register for instant access to their API, view their documentation, and even make live API calls with their interactive docs.
An API client library (also known as an SDK or language wrapper) is an efficiency tool for programmer that helps bind external resources to your native programming language. Traditionally, to integrate an API into your project without a client library, you would need to do the following:
Construct a network request using a transport library (e.g. HTTP)
Integrate authentication flow and signatures (e.g. OAuth, MD5/SHA-256, etc.)
Construct and execute API calls manually, often a trial and error process while reading documentation
Parse through results
Lather. Rinse. Repeat.
Client libraries make life easier by bringing the API into your native language environment. So, rather than making curl calls, piping the output into a variable, and parsing through the variable -- the client library handles the network connectivity, authorization and API call execution with syntax you're familiar with:
// Initialize the client library
$client = new apiClient();
// Set your API key
$client->setDeveloperKey("YOUR_KEY_HERE");
// Connect client to the API
$api = new apiService($client);
// Make an API call and store the response in an object
$StoryList = new StoryList($api -> ArticleMethods -> TopNews ("json","sports"));
// Iterate through the list of stories, and echo the titles
foreach ($StoryList->getStories() as $story) {
echo("Title: " . $story->getTitle());
}
Above is just a pseudo-PHP-code example of how this library works. If you'd like to see it in action, check out the example PHP files in this repo.
At Mashery, we love vim just as much as the next guy, but when it comes to tool-tips, code-completion and general object-oriented goodness, IDEs can be really useful. Eclipse, Aptana, Netbeans, Komodo, etc. They're all very mature and useful tools.
Follow the steps below for a quick start to using this client library:
Grab the latest source with git.
git clone git://github.com/mashery/io-wraps-usatoday-java.git
From the root of the unpack repo above, build with Maven:
maven install
Head over to USA TODAY Developer Network to fetch an API key
Open up your IDE and import the Maven project.
This client library was built using Mashery I/O Wraps, which incorporates the Google Client Library Generator and other Google native language libraries. This is why the package layout looks like com.google.api...