0

Im trying to retrieve the current difficulty value via api and parse the value only using JQ. In this example it is etherchains api. Currently my output is

curl 'https://etherchain.org/api/difficulty' | jq '.data'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    52  100    52    0     0    129      0 --:--:-- --:--:-- --:--:--   129
[
  {
    "difficulty": 666836759051894
  }
]

and I would like it to be

666836759051894

When I look at the jq manual https://stedolan.github.io/jq/manual/#Basicfilters it shows

    jq '.foo'
Input   {"foo": 42, "bar": "less interesting data"}
Output  42

What am I doing wrong?

2

Putting curl into silent mode first...

$ curl -s 'https://etherchain.org/api/difficulty' | jq '.data[][]'
666201861413999
  • what are the square brackets at the end doing? – sealfab Jun 12 '17 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.