Klimt is a Command Line Interface Metadata Tool. That almost spells Klimt. So close.
It makes it dead simple to view Artsy API json responses from the command line.
Klimt has four basic subcommands which will work with most REST-ful endpoints in the API (see caveat).
Supply the model name as it appears in the v1 API endpoint, and an id:
$ klimt find partner gagosian-gallery
$ klimt find artist damien-hirst
Supply the (usually plural) model name as it appears in the v1 API endpoint, and optionally some API parameters:
$ klimt list partners
$ klimt list partners eligible_for_listing=true near=30,-90
Supply the term to search for (enclosed in quotes if it contains whitespace), and optionally a list of space-delimited indexes to constrain the search.
$ klimt search "Gagosian Gallery"
$ klimt search Gagosian --indexes=Article Artwork
Supply the (usually plural) model name as it appears in the v1 API endpoint, and optionally some API parameters:
$ klimt count cultures
$ klimt count cultures nationalities=true
The find, list and count commands work great when the API endpoint in question is structured as a root-level endpoint rather than a nested one. So for now… /api/v1/partner/<id>
✔️ but /api/v1/partner/<id>/locations
❌.
See the discussion under "Gravity's v1 API" in Potential.
If a resource can't be retrieved because it's not a root-level endoint, or if some further custom behavior is desired, it's easy enough to create a new subcommand to encapsulate these requirements, e.g. the partner subcommand or the city subcommand.
For example, this partner subcommand results in several fetches and a detailed report:
$ klimt partner check-locations gagosian-gallery -x=-90 -y=30
Klimt — like the Heroku CLI client — uses Netrc to manage credentials. The first time you use it it will ask for a login, generate a token and save the token in ~/.netrc
.
JQ is a command line json pretty-printing and transformation tool that works great with Klimt
$ klimt list partners | jq '.[] | { id, name }'
$ klimt find partner moma-ps1 | jq '.name'
In fact Klimt will detect if JQ is installed, and if so will sometimes use it for nicer output, such as if you pass Klimt the --color
flag:
$ klimt find artist andy-warhol --color
Klimt is available as a RubyGem, so installation is as simple as:
# Set up your gravity keys, then…
$ gem install klimt
Klimt uses a Gravity ClientApplication
, whose id and secret you'll have to supply in your environment as KLIMT_ID
and KLIMT_SECRET
. (These are available in the shared 1Password vault — search for "Klimt env")
$ KLIMT_ID=<replace> KLIMT_SECRET=<replace> klimt help
Or just add these env variables to your shell startup script.
If you'd like auto-completion in zsh, add eval "$(klimt zsh-completion)"
to the end of your .zshrc
.