.Net DOL Data SDK

Add SDK files to your project

Extract the zipped SDK folder or grab the Git repository. Add the DOLDataUtil.cs file folder to your project.

Using the SDK

Reference the DOL Data API in your source file

In the source files that will make DOL Data requests add the following import:

using gov.dol.doldata.util;

Add service references to the DOL Data API

Use the Add Service Reference wizard to add a reference to the dataset(s) you want to connect to. This will generate a proxy class with strongly typed entities.

screen shot of add service reference menu

Making API Calls

The API is accessed via a service reference proxy class.  The DOLData API is a standard WFC Data Service (OData) producer, but requires an authorization header to be added to every request. The class included in this SDK provides the authorization handling for you.

In order to make requests:

  1. Define you API Key and Shared Secret in DOLDataUtil.cs
  2. //Define API Key and Shared Secret in DOLDataUtil.cs 
    private const string ApiKey =  "YOUR API KEY";
  3. Instantiate a ServiceReference Entity object
    // FormsServiceReference is a proxy class created by the "Add  Service Reference"
    // tool. Create new instance.
    FormsServiceReference.FormsEntities fe =
    new  FormsServiceReference.FormsEntities (new Uri("http://api.dol.gov/V1/FORMS"));
  4. Add an event handler to SendingRequest pointing to DOLDataUtil.service_SendingRequest
    //Attach event handler to the SendingRequest event
    //This will take care of adding the authorization header
    fe.SendingRequest  += new EventHandler<SendingRequestEventArgs>(DOLDataUtil.service_SendingRequest);
  5. Use Linq to query the data.
    //Use Linq to query the data
    //Example: Get top 10 agencies and output to console
    foreach (var form in  fe.Agency.Take(10))	
  6. For service calls like SummerJobs, use proxy to execute call.

    Pass the Service Operation name and paramters to the execute method.

    string jsonData = fe.Execute<string>(new Uri(
      UriKind.Relative)).FirstOrDefault().Replace("\\n", "").Replace("\\\"", "\"").Trim('\"');