Products

Charts

Resources

Products

Charts

Resources

Back to Blog

by Finage at July 22, 2020 1 MIN READ

Technical Guides

How to beautify cURL output in the terminal using jq

 

In this post, we will beautify the output of the cURL using jq. In this way, we can get more readable responses from the cURL and test our APIs easily.

 

 

 

Firstly, let’s make a simple API request to the Finage’s currency API using cURL. 

curl  "https://api.finage.co.uk/last?currencies=GBPUSD,EURUSD&apikey=YOUR_API_KEY"

This command will return an output given below.

 

 

As you can see, it’s hard to read. It’s a basic API call. Finage has more than 700+ symbols. This response could be more complicated. Let’s beautify it with jq.

 

Install jq

Install jq for MacOS

brew install jq

Install jq for Linux

sudo apt-get install jq

You can check jq’s page for more installation instructions for other platforms.

https://stedolan.github.io/jq/download/

 

 

Beautify & Parse with jq

Now, let’s change the request that we made using jq;

curl  "https://api.finage.co.uk/last?currencies=GBPUSD,EURUSD&apikey=YOUR_API_KEY" | jq '.'

This will return a response like this,

 

 

It’s more readable and easy to parse now. You can pick any property of the JSON response object like;

curl  "https://api.finage.co.uk/last?currencies=GBPUSD,EURUSD&apikey=YOUR_API_KEY" | jq '.lastUpdate'

It will return 

"2020-08-06T20:52:34"

Also, we can get only the property names or values from the response. Check the command below,

curl  "https://api.finage.co.uk/last?currencies=GBPUSD,EURUSD&apikey=YOUR_API_KEY" | jq '.currencies[].name'

 

 

 

With jq, you can test your APIs easily and make it readable. For more information about the jq, please visit the jq Manual.

You can check all available symbols in the Finage’s documentation. 

US Stock API Symbol List

Back to Blog

Request a consultation

Blog

Sector Focus: Which CFDs Are Investors Watching Closely This Year?

In the fast-paced world of finance, Contract for Differences (CFDs) remains a popular instrument among investors seeking to capitalize on the price movements of various assets without actually owning them. As we navigate this year, certain sectors are attracting significant attention due to their

What's New at Finage: Latest Features and Services for 2024

Anyone on the stock market knows how important data is. Getting quality information on current trends will make a difference between making profits or losses. Since its inception, various platforms offering real-time data solutions have been committed to enhancing data quality. Most of them are me

Read more

Please note that all data provided under Finage and on this website, including the prices displayed on the ticker and charts pages, are not necessarily real-time or accurate. They are strictly intended for informational purposes and should not be relied upon for investing or trading decisions. Redistribution of the information displayed on or provided by Finage is strictly prohibited. Please be aware that the data types offered are not sourced directly or indirectly from any exchanges, but rather from over-the-counter, peer-to-peer, and market makers. Therefore, the prices may not be accurate and could differ from the actual market prices. We want to emphasize that we are not liable for any trading or investing losses that you may incur. By using the data, charts, or any related information, you accept all responsibility for any risks involved. Finage will not accept any liability for losses or damages arising from the use of our data or related services. By accessing our website or using our services, all users/visitors are deemed to have accepted these conditions.

Finage LTD 2024

Copyright