{"id":15762282,"url":"https://github.com/glynnbird/ccurl","last_synced_at":"2025-05-07T02:23:36.878Z","repository":{"id":14033909,"uuid":"16736189","full_name":"glynnbird/ccurl","owner":"glynnbird","description":"CouchDB command-line tool to allow shortened curl commands without putting username/password in your command-line history","archived":false,"fork":false,"pushed_at":"2024-11-19T14:08:46.000Z","size":262,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T05:33:45.829Z","etag":null,"topics":["cli","cloudant","couchdb","json"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glynnbird.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-11T16:00:52.000Z","updated_at":"2024-11-19T14:08:51.000Z","dependencies_parsed_at":"2024-12-04T16:05:33.544Z","dependency_job_id":"75acb71e-18a1-4227-aca4-6d9cec0b4cf9","html_url":"https://github.com/glynnbird/ccurl","commit_stats":{"total_commits":47,"total_committers":3,"mean_commits":"15.666666666666666","dds":"0.14893617021276595","last_synced_commit":"78bb1a8e87af75de0bdef94e758548804a0134e0"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glynnbird%2Fccurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glynnbird%2Fccurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glynnbird%2Fccurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glynnbird%2Fccurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glynnbird","download_url":"https://codeload.github.com/glynnbird/ccurl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252434610,"owners_count":21747250,"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":["cli","cloudant","couchdb","json"],"created_at":"2024-10-04T11:08:28.596Z","updated_at":"2025-05-07T02:23:36.856Z","avatar_url":"https://github.com/glynnbird.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ccurl (couchdb curl)\n\nIf you use CouchDB, then you can access everything using [curl](https://curl.se/). The trouble is that it if you are using an authenticated, hosted service such as Cloudant's, then your credentials appear on your command-line history and there is a lot of typing. e.g.\n\n```sh\n  curl 'https://mypassword:MyPAssw0rd@myhost.cloudant.com/database/12345678'\n```\n\nWith *ccurl*, this becomes:\n\n```sh\n  ccurl /database/12345678\n```\n\nOr adding a document with curl:\n\n```sh\n  curl -X POST \\ \n       -H 'Content-type:application/json' \\ \n       -d'{\"a\":1,\"b\":2}' \\ \n       'https://mypassword:MyPAssw0rd@myhost.cloudant.com/database' \n```\n\nWith *ccurl*, this becomes:\n\n```sh\n  ccurl -X POST -d'{\"a\":1,\"b\":2}' /database \n```\n\n## Installing\n\n*ccurl* requires Node.js (and npm). Simply type:\n\n```sh\n  npm install -g ccurl\n```\n\n## Storing your credentials\n\nYour CouchDB credentials are taken from an environment variable \"COUCH_URL\". This can be set in your console with\n\n```sh\n  export COUCH_URL=\"https://mypassword:MyPAssw0rd@myhost.cloudant.com\"\n```\n\nor this line can be added to your `~/.bashrc`/`~/.bash_profile`/`~/.zshrc` file.\n\nIf you don't want credentials stored in your command-line history, you can set an environment variable by extracting the credentials from a file e.g.\n\n```sh\nexport COUCH_URL=`cat ~/.ibm/cloudant.json | jq -r .url`\n```\n\nwhere `~/.ibm/cloudant.json` is a JSON file that is readable only by my user containing the Cloudant service credentials. Even better store your your credentials in a password manager and extract them using CLI tools when needed:\n\n```sh\n# extract credentials from 1Password password manager\nexport COUCH_URL=`op read op://Private/CloudantBasic/website`\n```\n\n## Using IBM IAM Authentication\n\nIf you prefer to use IBM's IAM authentication for a Cloudant service set up two environment variables:\n\n- `COUCH_URL` - the URL of your Cloudant service e.g. `https://myurl.cloudant.com` (note the absence of authentication credentials).\n- `IAM_API_KEY` - the IBM IAM API key that identifies you.\n\n`ccurl` exchanges your API key for a \"bearer token\" which is automatically inserted into the request. `ccurl` keeps a cache of the bearer token for subsequent requests. It's stored in `~/.ccurl`. \n\nAgain, a password manager can help to keep these details secret:\n\n```sh\n# extract url and IAM api key from 1Password password manager\nexport COUCH_URL=`op read op://Private/CloudantIAM/hostname`\nexport IAM_API_KEY=`op read op://Private/CloudantIAM/credential`\n```\n\n## Using ccurl\n\n* All command-line switches are passed through to curl.\n* Instead of passing through a full url, pass through a relative url.\n* If the url is omitted, then a relative url of \"/\" is assumed.\n* The content-type of `application-json` is added for you if you don't already provide a content type.\n\n## Examples\n\n### Add a database\n\n```sh\n  \u003e ccurl -X PUT /newdatabase\n  {\"ok\":true}\n```  \n\n### Add a document\n\n```sh\n  \u003e ccurl -X POST -d'{\"a\":1,\"b\":2}' /newdatabase \n  {\"ok\":true,\"id\":\"005fa466b4f690ccad7b4d194f071bbe\",\"rev\":\"1-25f9b97d75a648d1fcd23f0a73d2776e\"}\n```\n\n### Get a document\n\n```sh\n  \u003e ccurl /newdatabase/005fa466b4f690ccad7b4d194f071bbe\n  {\"_id\":\"005fa466b4f690ccad7b4d194f071bbe\",\"_rev\":\"1-25f9b97d75a648d1fcd23f0a73d2776e\",\"a\":1,\"b\":2}\n```\n\n### Get ten documents\n\n```sh\n  \u003e ccurl '/newdatabase/_all_docs?limit=10\u0026include_docs=true' \n  {\"total_rows\":1,\"offset\":0,\"rows\":[{\"id\":\"005fa466b4f690ccad7b4d194f071bbe\",\"key\":\"005fa466b4f690ccad7b4d194f071bbe\",\"value\":{\"rev\":\"1-25f9b97d75a648d1fcd23f0a73d2776e\"},\"doc\":{\"_id\":\"005fa466b4f690ccad7b4d194f071bbe\",\"_rev\":\"1-25f9b97d75a648d1fcd23f0a73d2776e\",\"a\":1,\"b\":2}}]}\n```\n\n### Remove a database\n\n```sh\n  \u003e ccurl -X DELETE /newdatabase\n  {\"ok\":true}\n```  \n\n### Other curl command-line parameters work too\n\n```sh\n  ccurl -h\n  ccurl -v\n  etc. \n```\n\n## Using ccurl with jq\n\nIf [jq](http://stedolan.github.io/jq/) is installed, *ccurl* automatically pipes the curl output to `jq .`, when stdout is a terminal. You may also do the piping yourself to extract a subset of the data e.g\n\n```sh\n ccurl '/newdatabase/_all_docs?limit=10\u0026include_docs=true' | jq '.total_rows'\n```\n\nor \n\n```sh\n ccurl '/newdatabase/_all_docs?limit=10\u0026include_docs=true' | jq '.rows[0].doc.name | length'\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglynnbird%2Fccurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglynnbird%2Fccurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglynnbird%2Fccurl/lists"}