1. Home
  2. Article Catalog
  3. Easy Retrieving Historical Pricing Events Data in JSON using Jackson


Easy Retrieving Historical Pricing Events Data in JSON using Jackson

Pimchaya Wongrukun
Developer Advocate Developer Advocate


Refinitiv Data Platform (RDP) provides access to Refinitiv data e.g. historical pricing events, interday historical pricing summaries and news using REST API via Cloud technologies. In this article, I will demonstrate how easy to use Jackson for retrieving historical pricing events data in JSON response received from RDP to create a table (.CSV file) like the figure below. 

The table contains the values of name and type in headers key and the values of data key in JSON response.


  1. RDP access credentials (username, password and clientId) which can retrieve historical pricing events data.  Please reach out to your Refinitiv account team to acquire username and password. You can generate clientId from App key Generator.
  2. EDPToken class to get an access token which is as part of any data request sent to RDP.  For more details of EDPToken class and its source code, please refer to Easy Obtaining Token from RDP Gateway in Java article.

Using Jackson to Retrieve Data in JSON Response

The overview process is the following diagram: 

Firstly, you need to have a Java class (the top gray box in the diagram) which matches the format of the data JSON response. The steps to create the Java class are described in the next section.

Then, you can use Jackson ObjectMapper to read the Java class and JSON response received from RDP to create a Java object representing the parsed JSON. Then, you can call methods of the Java object to get any values of parsed JSON.

In my application, I will get the values of data key, name and type in headers key by calling the methods of HistoricalPricingEvent object.  The snipped source code is shown below:


//Jackson ObjectMapper reads HistoricalPricingEvents class and historical pricing events JSON response 

//to create an object representing the parsed JSON.    

HistoricalPricingEvent eventsData = new ObjectMapper().readerFor( HistoricalPricingEvent.class)


//get the values of data key in the object

List<List<String>> data =  (List<List<String>>)eventsData.getData();

//Get the values of headers key in the object

List<Header> headers= eventsData.getHeaders();

//Get the values of name and type key in headers 

Iterator<Header> hiterator = headers.iterator();

while(hiterator.hasNext()) {

Header aheader = (Header)hiterator.next();

String name = aheader.getName();

String type = aheader.getType();


Then, I can use the values to create a table which shows historical pricing events data as explained in Introduction section.

HistoricalPricingEvent class can be generated by http://www.jsonschema2pojo.org/ . This is explained in Creating Java Class which matches JSON Response from RDP section.

Anyway, you can find the complete application source code including HistoricalPricingEvent class in Article.EDP.Java.HistoricalPricingEvents on Github.

Creating Java Class which matches JSON Response from RDP

Instead of writing the full Java class manually, I will use http://www.jsonschema2pojo.org/ page which can generate Java class with Jackson annotation from JSON, and JSON schema. Please follow these steps to create Java class from the JSON schema of historical pricing events data JSON response.

  1. Go to API Playground and find the /data/historical-pricing/ service. Then, select the /views/events/{universe} path.

2. Select the Swagger menu to download the JSON schema file.

3. Open the schema file. Under /views/events/{universe}, find the successful response(200 HTTP status code) which contains data. The response refers to the value in /definitions/historicalPricingData path.

Copy the value in the /definitions/historicalPricingData path:

Paste the value in the text box on http://www.jsonschema2pojo.org/

4. Look into the value in the text box, find $ref which refers to /definitions/status path:

Copy the value in the /definitions/status path that $ref refers to:

Replace $ref line with the copied value:

The complete JSON schema in the text box (the step 3-4) is dataResponseJson.zip under DOWNLOADS section below.

5. Set Package and Class name e.g. com.java.response and HistoricalPricingEvent respectively.  At Source type, select JSON Schema. The Class name is the name of Java class which matches the format of JSON schema.

6. Click Zip button. Then, the Java classes are generated and compressed in the zip file. Finally, the zip file name is shown:

Click the zip name file to download. 

     When you uncompress the zip file, you will see the Java class file (HistoricalPricingEvent) and the related classes as below:

Compile and Run Application

Before you can compile and run the application, you have to set the CLASSPATH to point to Apache Http Components, JSON in java, Jackson Core, Jackson Annotations and Jackson Databind like an example on Windows machine below:

set CLASSPATH=C:\thirdPartyJars\httpcomponents-client-4.5.9\lib\commons-codec-1.11.jar;C:\thirdPartyJars\httpcomponents-client-4.5.9\lib\commons-logging-1.2.jar;C:\thirdPartyJars\httpcomponents-client-4.5.9\lib\httpclient-4.5.9.jar;C:\thirdPartyJars\httpcomponents-client-4.5.9\lib\httpcore-4.4.11.jar;C:\thirdPartyJars\JsonInJava\json-20180813.jar;C:\thirdPartyJars\commons-cli-1.4\commons-cli-1.4.jar;C:\thirdPartyJars\Jackson\jackson-annotations-2.9.9.jar;C:\thirdPartyJars\Jackson\jackson-core-2.9.9.jar;C:\thirdPartyJars\Jackson\jackson-databind-2.9.9.jar

The java command line to request the latest 5 quote events of RIC THB= using the application is below:

java -classpath %CLASSPATH%;. com.java.HistoricalPricingEventsRequestor -user <RDP username> -clientId <clientId> -rics THB= -events quote -count 5

The example output:

Finally, the application writes historical pricing events data in a CSV file like an example below:


This article explains how to use Jackson to retrieve historical pricing events data in JSON response received from RDP. It also suggests http://www.jsonschema2pojo.org/  which can generate the Java class from JSON response schema. Jackson requires this Java class for parsing a JSON response into an Object of this Java class. Moreover, you can use the techniques in this article and the application source code to apply for another data from RDP.