Skip to content
Run GROQ in your command line
Branch: master
Clone or download
Latest commit 0a6e7df Jul 10, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin first commit Jul 10, 2019
src first commit Jul 10, 2019
.editorconfig first commit Jul 10, 2019
.eslintrc first commit Jul 10, 2019
.gitattributes first commit Jul 10, 2019
.gitignore first commit Jul 10, 2019
.npmrc first commit Jul 10, 2019
.travis.yml first commit Jul 10, 2019
license first commit Jul 10, 2019
package.json 0.1.0 Jul 10, 2019
readme.md Add links Jul 10, 2019

readme.md

groq-cli

Currently in alpha.

Easy wrangling of JSON documents with GROQ in the command line.

The CLI tool consumes both JSON and NDJSON documents. You can pass in data from a local file, or from piping to standard input.

Read the announcement blog post, and the getting started guide.

Install

npm install --global groq-cli

Requirements

This CLI requires Node v10 or later.

Usage

$ groq --help

  Usage
    $ groq '*[<filter>]{<projection>}'
    # Remember to alternate quotation marks inside of the query

  Options
    --file  ./path/to/file
    --url https://aniftyapi.dev/endpoint
    --pretty colorized JSON output [Default: false]

  Examples
    # Query data in a ndjson-file
    $ groq '*[_type == "post"]{title}' --file ./blog.ndjson

    # Query JSON data from an URL
    $ groq '*[completed == false]{title}' --url https://jsonplaceholder.typicode.com/todos

    # Query data from stdIn
    $ curl -s https://jsonplaceholder.typicode.com/todos | groq "*[completed == false]{'mainTitle': title, ...}" --pretty

Similar tools

GROQ-cli isn't the only tool to work with JSON data in the command line. If it doesn't do exactly what you need, you can scheck out these other tools that might help you:

  • jq — a lightweight and flexible command-line JSON processor.
  • gron - Make JSON greppable!

License

MIT – Copyright 2019–present Sanity Inc.

You can’t perform that action at this time.