Example Code


Below we have several examples that demonstrate how to use the USA Spending Client.

Example 1

The following example executes a request for ALL the information available for the given search criteria for sub-award data — note that all requests to the USA Spending web services follow the same pattern.

The QueryBuilder takes an instance of the Spring Framework’s RestTemplate and the URL to the USA Spending endpoint and returns an instance of the class that pertains to that web service.

The QueryBuilder allows the developer to take advantage of method chaining so as to create a single query that includes all of the request parameters; the developer then executes the query by invoking the execute method.

QueryBuilder builder = new QueryBuilder(

Complete complete =

Example 2

The integration tests provide a comprehensive set of examples to assist the developer — see here.

Example 3

An advanced example is available at Bitbucket here.