{"id":27958066,"url":"https://github.com/ericsson/jaq","last_synced_at":"2025-05-07T18:16:15.030Z","repository":{"id":57746673,"uuid":"151527718","full_name":"Ericsson/jaq","owner":"Ericsson","description":"jaq is a CLI tool for scripting and chaining JSON API requests.","archived":false,"fork":false,"pushed_at":"2018-10-09T17:29:41.000Z","size":1633,"stargazers_count":44,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-07T18:16:04.838Z","etag":null,"topics":["api","ericsson","json","json-api","scripting"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ericsson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-04T06:25:08.000Z","updated_at":"2023-02-10T10:51:16.000Z","dependencies_parsed_at":"2022-09-01T18:52:05.539Z","dependency_job_id":null,"html_url":"https://github.com/Ericsson/jaq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ericsson%2Fjaq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ericsson%2Fjaq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ericsson%2Fjaq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ericsson%2Fjaq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ericsson","download_url":"https://codeload.github.com/Ericsson/jaq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931507,"owners_count":21827112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","ericsson","json","json-api","scripting"],"created_at":"2025-05-07T18:16:13.853Z","updated_at":"2025-05-07T18:16:14.993Z","avatar_url":"https://github.com/Ericsson.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jaq\nCLI tool for chaining JSON API requests.\n\n[![Build Status](https://travis-ci.com/Ericsson/jaq.svg?branch=master)](https://travis-ci.com/Ericsson/jaq)\n\njaq simplifies running multiple, related API commands such as getting IDs or other fields from one endpoint for use in another query.\n - Uses a config file to avoid repetition on the command-line\n - Set URL paths, query strings, or headers\n - Pipe output from one endpoint to another\n - Ability to \"explode\" a JSON list into separate elements for separate processing\n\n## Installation\n\n1. Clone the repo \u0026 run `go install`\n2. Setup a small config file at ~/.jaq.json:\n3. Run commands!\n\n```bash\ngo get github.com/Ericsson/jaq \u0026\u0026 go install\necho '{\"domain\":\"jsonplaceholder.typicode.com\"}' \u003e ~/.jaq.json\njaq get /posts\n```\n\nAlthough not a requirement, jaq works really well if you are using [jq](https://github.com/stedolan/jq) as well for JSON querying/filtering.\n\n## Examples\n\nThese examples assume you are have the jq tool available since we do not try to duplicate its capabilities.\n\n\u003e **NOTE**\n\u003e jaq consumes the `$` as a special character so the commands below escape it so it is not consumed by your shell.\n\n```bash\n# Examples assume config file\necho '{\"domain\":\"jsonplaceholder.typicode.com\"}' \u003e ~/.jaq.json\n\n# Get objects from an endpoint\njaq get /posts\n\n# Delete all the objects by id which have userId == 3\njaq get /posts | jq -c '.[] | select(.userId == 3)' | jaq delete /posts/\\${1.id}\n\n# Get comments from the 3 most recent posts\njaq get /posts | jq -c .[-3:] | jaq get /comments -q postId=\\${1.id}\n\n```\n\n## Configuration\n\njaq uses a configuration file (defaults to ~/.jaq.json but configurable via a flag) to make your commands more succinct.\n\nYou can also override most settings in the configuration file by using environment variables with similar keys. Use env vars of the form: `JAQ_\u003cKEY_NAME\u003e` to set the value of \"key-name\". (Env vars must be upper cased, prefixed with `JAQ_` and hyphens replaced with underscores.\n\n### Auth\n\nThe auth setting can switch which authorization scheme to use by default. Currently the supported types are:\n - `basic` - Will use the \"user\" and \"pass\" fields to set the Authorization header.\n - `token` - Will set the header \"Authorization: Bearer \\\u003ctoken\\\u003e\"\n\n### dry-run\n\nThe dry-run setting allows you to try out potentially destructive commands and ensure all the input transformations result in the expected commands.\n\nWhen running in dry-run mode, all of the input transformations occur but the resulting commands are just printed to stdout rather than actually being run.\n\n### Printing headers\n\nSince jaq operates by piping JSON over stdin, if you want to use a header field you must include it in the JSON from the response. To facilitate this, when `--print-headers` is set, all of the headers are added as new JSON fields on all the JSON objects of the response with the prefix `jaq-`.\n\n### Error handling\n\nYou may want different behavior when encountering an error (HTTP response \u003e= 400). Options are:\n\n - `silence` - Completely ignore those responses and do not print them or error.\n - `fatal` - Print them to stderr and return an error.\n - `continue` - Print the responses to stdout as if they were not errors and continue.\n - `report` - Print the responses to stderr so they do not pollute stdout for other piped commands.\n\n### Trace/Debug\n\nWhen executing commands you may want an entire dump of the HTTP request/response. By specifying `--trace` the request/response will be dumped to stderr (so that it doesn't interfere with the JSON on stdout). By default, the body of the requests are _NOT_ dumped. You can set `--DEBUG` to also add the body of the request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericsson%2Fjaq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericsson%2Fjaq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericsson%2Fjaq/lists"}