1

I'm trying to filter JSON file after I'm pulling it over Curl using JQ to have only Youtube video "id" printed with jq from Ubuntu shell, with no luck I need to have XEJLuJyxLDE after "id": only , pretty long list and I'm very new to linux and jq. Thanks for help. My command now is which doesn't work curl -s 'https://www.googleapis.com/youtube/v3/videos?chart=mostPopular&locale=RU&maxResults=50&key=MY_API_HERE' --header 'Accept: application/json' | jq ".id"


 {
  "kind": "youtube#videoListResponse",
  "etag": "peo7sRMHdYZRkNABiJLj7xYZ0yo",
  "items": [
    {
      "kind": "youtube#video",
      "etag": "DrIQh9Tabqk3iak4yonUCzJ3sTk",
      "id": "XEJLuJyxLDE"
    },
    {
      "kind": "youtube#video",
      "etag": "1pZQ8jDaavX6KnOyiFrHQQiZtHo",
      "id": "jO0luDEHesc"
    },
    {
      "kind": "youtube#video",
      "etag": "EJZ20jnqkqp7uTg5krUSK1SQE5s",
      "id": "ixl31324UxE"
    },
    {
      "kind": "youtube#video",
      "etag": "lGhY08GhkmvKFuDL-GWAc0ulq-4",
      "id": "EoxkdcQAZmQ"
    },
    {
      "kind": "youtube#video",
      "etag": "C8wQv894QbhKLeMUH0qR4cVVi7w",
      "id": "5nFpkCmb8e4"
    },
    {
      "kind": "youtube#video",
      "etag": "zgizGmrn5tpxE6x2Yb0Dbuays1E",
      "id": "tJvCygyNH4I"
    },
    {
      "kind": "youtube#video",
      "etag": "WnwrLmfpC1sLxZaQjQdF6LIKrck",
      "id": "racmy7Y9P4M"
    },
    {
      "kind": "youtube#video",
      "etag": "1Ye2Py_uXwlz25tukvCklZK9094",
      "id": "rDpC8RW6UIQ"
    },
    {
      "kind": "youtube#video",
      "etag": "_4CqgWptBzjcBVxNvgZj9Rc60Ws",
      "id": "ONAZ__UY8Ps"
    },
    {
      "kind": "youtube#video",
      "etag": "6Ft6e-4d96bOZz8ICutRq1V9UNs",
      "id": "RE8VF-mVkhw"
    },
    {
      "kind": "youtube#video",
      "etag": "aQQyXts43CxaFmtTIHDgPAPIUnE",
      "id": "LVze229omm4"
    }

1 Answer 1

3

You can use:

jq '.items[].id'

to retrieve all ids.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.