{"id":21336822,"url":"https://github.com/dan-da/jsonrpc-cli","last_synced_at":"2025-08-11T18:22:09.232Z","repository":{"id":72068134,"uuid":"190222408","full_name":"dan-da/jsonrpc-cli","owner":"dan-da","description":"jsonrpc-cli is a command-line tool that performs json-rpc queries","archived":false,"fork":false,"pushed_at":"2023-11-05T19:51:23.000Z","size":159,"stargazers_count":24,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-16T22:29:23.175Z","etag":null,"topics":["bitcoin","bitcoin-cli","cli","commandline","json-client","jsonrpc","shell"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dan-da.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,"governance":null}},"created_at":"2019-06-04T14:52:44.000Z","updated_at":"2024-04-16T22:29:23.176Z","dependencies_parsed_at":"2023-11-05T20:28:53.607Z","dependency_job_id":null,"html_url":"https://github.com/dan-da/jsonrpc-cli","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fjsonrpc-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fjsonrpc-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fjsonrpc-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dan-da%2Fjsonrpc-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dan-da","download_url":"https://codeload.github.com/dan-da/jsonrpc-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225820222,"owners_count":17529139,"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":["bitcoin","bitcoin-cli","cli","commandline","json-client","jsonrpc","shell"],"created_at":"2024-11-21T23:55:30.388Z","updated_at":"2024-11-21T23:55:31.045Z","avatar_url":"https://github.com/dan-da.png","language":"PHP","readme":"**jsonrpc-cli is a command-line tool that performs json-rpc queries**\n\n\n# About\n\nThis tool is useful for manually performing single json-rpc queries from the command-line.\n\nTypically this is useful for debugging purposes or one-off needs.\n\nA distinguishing feature of this client is that it supports logging the raw HTTP communications\n(request, headers, response) to a logfile.  So one can see exactly what is sent to the server\nand what it returns.\n\nThe tool also colors the results (syntax highlighting) and can output results in multiple structured data\nformats such as json, yaml, print_r, var_dump, and php's serialization format.\n\n# Motivation\n\nI built this tool because I needed to debug json-rpc interactions between two third-party tools.  I wanted\nto see exactly what http headers are sent and exactly what the server responds with, but existing json-rpc\ntools and libraries I found did not support this.\n\n\n# Examples\n\n## Basic typical usage\n\nBy default, only the value of the \"result\" field of the server's json-rpc response will be displayed.\n\n```\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword  http://localhost:28332/ getblockcount\n\n588589\n```\n\n## With method parameters\n\n### params as separate command-line args\n\n```\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword   http://localhost:28332/ estimatesmartfee 1 ECONOMICAL\n\n{\n    \"_feerate\": \"0.00027031\",\n    \"blocks\": 1,\n    \"feerate\": 0.00027031\n}\n```\n\n### params as a json string\n\n```\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword   http://localhost:28332/ estimatesmartfee '[1,\"ECONOMICAL\"]'\n\n{\n    \"_feerate\": \"0.00027031\",\n    \"blocks\": 1,\n    \"feerate\": 0.00027031\n}\n```\n\n## Server's full json response.\n\nFor this, we specify --resultonly=off\n\n```json\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword --resultonly=off  http://localhost:28332/ getblockcount\n\n{\n    \"error\": null,\n    \"result\": 588590,\n    \"id\": 2048885931,\n    \"jsonrpc\": \"2.0\"\n}\n```\n\n\n### Need to debug?  We can log the full http request and response to a file.\n\n```\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword --format=raw --httpfile=/tmp/http.log  http://localhost:28332/ getblockcount\n\n{\"error\": null, \"result\": 588593, \"id\": 941852157, \"jsonrpc\": \"2.0\"}\n\n$ cat /tmp/http.log\nPOST / HTTP/1.0\nAccept: text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*\nAccept-Language: en-us\nHost: localhost\nUser-Agent: Mozilla/4.0 (compatible; jsonrpc-cli HTTP Client; Linux)\nConnection: Close\nContent-Length: 57\nAuthorization: Basic cnBjdXNlcjpycGNwYXNzd29yZA==\nCookie: \n\n{\"jsonrpc\":\"2.0\",\"method\":\"getblockcount\",\"id\":941852157}\n\nHTTP/1.0 200 OK\nContent-Type: application/json; charset=utf-8\nContent-Length: 68\nDate: Sun, 04 Aug 2019 16:09:41 GMT\nServer: Python/3.5 aiohttp/3.0.0b0\n\n{\"error\": null, \"result\": 588593, \"id\": 941852157, \"jsonrpc\": \"2.0\"}\n```\n\n## We can also display the result data in other formats.\n\nAvailable formats are raw|json|jsonpretty|yaml|printr|vardump|serialize\n\n\n### Let's see the server's raw response without any formatting.\n\n```\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword --format=raw  http://localhost:28332/ getblockcount\n\n{\"error\": null, \"result\": 588593, \"id\": 641121075, \"jsonrpc\": \"2.0\"}\n```\n\n\n### yaml example\n\n```yaml\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword --format=yaml  http://localhost:28332/ getblockchaininfo\n\npruned: false\nbestblockhash: \u003e\n  0000000000000000001babf6c3e29d839db7b208dfab64948b015796a8b45a72\nheaders: 588593\nblocks: 588593\nchain: main\ndifficulty: null\nchainwork: null\nwarning: \u003e\n  spruned 0.0.2a3, emulating bitcoind\n  v0.16\nverificationprogress: 100\nmediantime: 1564934597\n```\n\n### printr example\n\n```\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword --format=printr  http://localhost:28332/ getblockchaininfo\n\nArray\n(\n    [pruned] =\u003e \n    [bestblockhash] =\u003e 0000000000000000001babf6c3e29d839db7b208dfab64948b015796a8b45a72\n    [headers] =\u003e 588593\n    [blocks] =\u003e 588593\n    [chain] =\u003e main\n    [difficulty] =\u003e \n    [chainwork] =\u003e \n    [warning] =\u003e spruned 0.0.2a3, emulating bitcoind v0.16\n    [verificationprogress] =\u003e 100\n    [mediantime] =\u003e 1564934597\n)\n```\n\n# Use at your own risk.\n\nThe author makes no claims or guarantees of correctness.\n\nBy using this software you agree to take full responsibility for any losses\nincurred before, during, or after the usage, whatsoever the cause, and not to\nhold the software author liable in any manner.\n\n\n# Output formats\n\nThe output may be printed in the following formats:\n* jsonpretty - pretty-printed json.  ( default )\n* json       - compact json\n* yaml       - pretty printed yaml\n* raw        - raw text response from server\n* printr     - tree format using php's print_r() function\n* vardump    - tree format using php's var_dump() function\n* serialize  - tree format using php's serialize() function\n\n# Highlighting / colors\n\nColored output is available for all formats except raw.\n\nUse the flag --highlight=on (default) or --highlight=off to disable.\n\nExamples:\n\n![Image](doc/image/example1.png?raw=true)\n\n![Image](doc/image/example2.png?raw=true)\n\n![Image](doc/image/example3.png?raw=true)\n\n\nOr, if you use the one true Green on Black background:\n![Image](doc/image/example4.png?raw=true)\n\n# Errors\n\nExceptions are displayed as structured data, according to --format flag and can be easily read\nby a calling program.\n\n```yaml\n$ ./jsonrpc-cli --user=rpcuser --pass=rpcpassword --format=yaml  http://localhost:28332/ getblockchaininfos\nmessage: HTTP/1.0 404 Not Found\nclass: JsonRPC\\Exception\\NotFoundException\ncode: 404\nfile: \u003e\n  /tmp/jsonrpc-cli/vendor/dan-da/json-rpc/src/JsonRPC/HttpClient.php\nline: 654\ntrace:\n  - '/tmp/jsonrpc-cli/vendor/dan-da/json-rpc/src/JsonRPC/HttpClient.php:324 in JsonRPC\\HttpClient-\u003ehandleExceptions'\n  - '/tmp/jsonrpc-cli/vendor/dan-da/json-rpc/src/JsonRPC/HttpClient.php:152 in JsonRPC\\HttpClient-\u003esendRequest'\n  - '/tmp/jsonrpc-cli/vendor/dan-da/json-rpc/src/JsonRPC/HttpClient.php:159 in JsonRPC\\HttpClient-\u003epost'\n  - '/tmp/jsonrpc-cli/vendor/dan-da/json-rpc/src/JsonRPC/Client.php:195 in JsonRPC\\HttpClient-\u003eexecute'\n  - '/tmp/jsonrpc-cli/vendor/dan-da/json-rpc/src/JsonRPC/Client.php:177 in JsonRPC\\Client-\u003esendPayload'\n  - '/tmp/jsonrpc-cli/src/AppCore.php:66 in JsonRPC\\Client-\u003eexecute'\n  - '/tmp/jsonrpc-cli/jsonrpc-cli:43 in App\\AppCore-\u003erequest'\n  - /tmp/jsonrpc-cli/jsonrpc-cli:73 in main\n```\n\n# Usage\n\n```\n$./jsonrpc-cli --help\n\n   jsonrpc-cli.php [options] \u003curl\u003e \u003cmethod\u003e [params]\n\n   This script makes a request to a jsonrpc server.\n   \n   params may be provided as either:\n     (a) space separated scalar values, eg: \"6\" or \"6\" \"7\"  -- or --\n     (b) json values, eg: \"[6] or \"[6,7]\", or '{color: \"red\", size: \"small\"}'\n         \n         note: json values can have nested arrays or objects. \n\n   Options:\n   \n    --user=\u003cuser\u003e        username for http basic auth\n    --pass=\u003cpass\u003e        password for http basic auth\n\n    --outfile=\u003cpath\u003e     specify output file path.\n    \n    --timeout=\u003cs\u003e        request timeout in secs.  default = none.\n    \n    --format=\u003cformat\u003e    [ raw|json|jsonpretty|yaml|printr|vardump|serialize|all ]\n                           \n                         default=jsonpretty\n                         \n                         raw will print response exactly as received from\n                         server (after http chunk decoding) even if invalid json.\n    \n                         if 'all' is specified then a file will be created\n                         for each format with appropriate extension.\n                         only works when outfile is specified.\n                         \n    --resultonly=\u003cflag\u003e  [ on | off ]   default = on.\n                           on  --\u003e display \"result\" key of server's json response.\n                           off --\u003e display server's entire json response.\n                           \n                           note: --format=raw forces --resultonly=off\n                         \n    --highlight=\u003cflag\u003e   [ on | off ]   default = on.\n                           highlights output if possible, depending on --format.\n\n    --logfile=\u003cpath\u003e    path to logfile. if not present logs to stdout.\n    --loglevel=\u003clevel\u003e  debug,info,specialinfo,warning,exception,fatalerror\n                          default = info\n                          \n    --httpfile=\u003cpath\u003e   writes raw http request, headers, and response to a file.\n```\n\n\n# Installation and Running.\n\nUbuntu 16.04 requirements:\n```\n$ apt-get install php composer\n```\n\nBasics\n```\n$ git clone https://github.com/dan-da/jsonrpc-cli\n$ cd jsonrpc-cli\n$ composer install\n$ ./jsonrpc-cli --help\n```\n\n\n# Todos\n\n* read method parameters from stdin\n* make test cases\n* Support batching (maybe)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fjsonrpc-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan-da%2Fjsonrpc-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan-da%2Fjsonrpc-cli/lists"}