Project

klimt

0.0
No commit activity in last 3 years
No release in over 3 years
CLI for the Artsy API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 9.0
~> 10.0
~> 3.0
~> 0.47
~> 2.3

Runtime

~> 1.7
~> 0.11
~> 0.19
~> 1.1
 Project Readme

Klimt

CircleCI Build Status

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.

Usage

Klimt has four basic subcommands which will work with most REST-ful endpoints in the API (see caveat).

View a resource

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

List a collection of resources

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

Find a resource via term search

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

Count a resource

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

Caveat re: root-level endpoints

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.

Custom subcommands

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

Authentication

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.

Klimt 💖 JQ

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

Installation

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.