Example Code

Introduction [ Examples ] Source Code | Maven | Java Documentation (core only) | Caching | Try it | Property Change Notifications

Try it

Get acclimated with the FRED Client API using the new demonstration application.


Below we have several examples that demonstrate how to use the FRED Client. Note that the developer can request data from the FRED web service and then save the result to a database — refer to example 4 below to see how this works.

Example 1

The following example executes a series search — note that all requests to the FRED web services follow the same pattern.

The QueryBuilder takes an instance of the Spring Framework’s RestTemplate and the URL to the FRED 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(

Seriess seriess = builder
    .series ()
    .search ()
    .setSearchText("money stock")

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 SourceForge here or you can check out a copy of the project from Subversion using the following command:

svn checkout svn://svn.code.sf.net/p/clfredclient/code/trunk clfredclient-code

Example 4

The FRED Client domain classes have been annotated with Java Persistence API (JPA) annotations so that the developer can make a call to the FRED service and save the result to a database.

The example above can be saved to the database as follows:


Click here to see an example data access object test.

Leave a Reply

Your email address will not be published. Required fields are marked *