.NET Client NuGet Package

.NET Client

The NZOR.Web.Service.Client is a light weight readonly .NET client wrapper designed to make access to the NZOR Web API simpler.

It is available as a NuGet package so that it can be easily incorporated into an application.

1 PM> Install-Package NZOR.Web.Service.Client

Example Usage

Note: In the following examples an API key is not currently required.

Be sure to include the following namespace

1 using NZOR.Web.Service.Client;

The ServiceClient class is the main class for interacting with the API.

Retrieve a single name record

The following code is a small snippet that demonstrates how to display the result of retrieving a name.

1 2 3 4 5 var serviceClient = new ServiceClient("mykey", "http://data.nzor.org.nz"); var name = serviceClient.GetName(new Guid("61ccb72c-d60f-4cc0-a124-863869a2e2f4")); Console.WriteLine(name.FullName);

More details about the structure of a name can be found on the API pages describing the name resource. 

To use the search functionality of the client it is necessary to include the following namespace

1 using NZOR.Publish.Model.Search;

The following code shows the basics for querying a name and iterating through the results.

1 2 3 4 5 6 7 8 9 10 11 12 13 var serviceClient = new ServiceClient("mykey", "http://data.nzor.org.nz");   var searchRequest = new SearchRequest(); searchRequest.Query = "lich*"; searchRequest.PageSize = 10; var searchResponse = serviceClient.Search(searchRequest); foreach (var result in searchResponse.Results) { Console.WriteLine(result.Name.FullName); }

Show the classification hierarchy for a name record

The following code enumerates the classification hierarchy for a name. The name information for each ancestor only includes the basic details for display so it may be necessary to make a separate call for each record using the name Id to obtain more details information.

1 2 3 4 5 6 7 8 9 10 11 12 13 var serviceClient = new ServiceClient("mykey", "http://data.nzor.org.nz"); var name = serviceClient.GetName(new Guid("000018af-1183-46f7-8d80-0729ae07401f")); Console.WriteLine(name.FullName); Console.WriteLine(); foreach (var ancestorName in name.ClassificationHierarchy) { Console.WriteLine(String.Format("{0}: {1}", ancestorName.Rank, ancestorName.FullName)); } Console.ReadKey();