First thing’s first:

If you haven’t already, you’ll need to go to http://ISBNdb.com and sign up for a developer account. Once you’ve done this step, and you’ve got your new, shiney API-key in hand, you’ll be able to start using this library in any of your managed .NET 4.0+ projects.

Next, you’ll need to add the summerset.isbndb.dll reference to your project.

>> Note: The assembly that I’ve posted to the codeplex page is not signed. If the assembly that you’re producing is signed, then you will need to download the source code, apply your own key file, then compile and use that assembly.

 

On to actual usage:

The usage of this library is very simple. Before we get started, just for brevity, I’m going to assume that you’ve added the following 'using’ statements:

using Summerset.Isbndb;
using Summerset.Isbndb.Authors;

Step 1: Instantiate an Isbndb object

/* create an instance of Isbndb and provide your API key to it’s constructor */

var api = new Isbndb("MY-API-KEY-HERE");

Step 2: Build a query

/* Decide which of the 5 collections you’re going to query,
* each of the 5 Isbndb.com collections is represented by it’s own namespace in this library. For our example, we’re going to query the ‘authors’ collection.
* To query our authors collection we need to setup our query object, and then provide that to the Isbndb instance we made in step one.
* Each query object is called ‘collectionnamespaceRequest’ .. ex, AuthorsRequest.
* In our example below, we’re going to query the API for any authors named Jimmy Buffett.
*/

var request = new AuthorsRequest(
AuthorsArgs.Arguments.name, // the name of the index our search terms will query. Valid arguments for the authors collection are provided in the AuthorsArgs.Arguments static class.
“Jimmy Buffett”, // the actual search terms
AuthorsArgs.Results.categories); // the name of any additional results we want to get back. You may provide multiple values here, or you may omit this parameter all-together. Valid arguments are provided in the AuthorsArgs.Results static class

Step 3: Execute the query

/* Results returned from ISBNdb.com are paginated, with a maximum of 10 elements per page. So, in this case we’d be looking at a maximum of 10 authors per page.
* The default behavior is that our response object will load the first page synchronously. Then it will load subsequent pages synchronously as they’re requested.
*/

var response = api.ExecuteAuthorRequest(request);

Step 4: Use the results

/* In our example, we’re going to write every the name of every author on the first page of results, their isbndb.com-specific id, and finally the name of all the subjects that’ve authored publications in. Remember the first page is always loaded automatically. After that, the default behavior is that pages won’t be loaded until they’re requested. This keeps your usage of the API to a minimum. As of July 2012, there is a 500 request per-day limit for free accounts. */

var firstPage = response.Pages.First();
foreach (var author in firstPage.Items)
Console.WriteLine(author.AuthorId + " - " + author.Name + " : " + string.Join(",", author.Categories.Select(e => e.Text))); 

Last edited Jul 23, 2012 at 9:13 PM by djcurtis, version 1

Comments

No comments yet.