Skip to main content

Add a thin wrapper around the Flickr API

ID
4751b87
date
2023-10-12 08:04:37+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
f8a054f
message
Add a thin wrapper around the Flickr API
changed files
1 file, 22 additions

Changed files

flapi (0) → flapi (444)

diff --git a/flapi b/flapi
new file mode 100755
index 0000000..fe9afd6
--- /dev/null
+++ b/flapi
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+# A thin wrapper around the Flickr API.
+#
+# I use this to do quick inspection of API responses, e.g.
+#
+#     $ flapi flickr.photos.getInfo photo_id=52782497889
+#
+
+set -o errexit
+set -o nounset
+
+if (( $# != 2 ))
+then
+  echo "Usage: $0 <METHOD> <PARAMS>" >&2
+  exit 1
+fi
+
+method="$1"
+params="$2"
+api_key=$(keyring get flickr_api key)
+
+curl "https://api.flickr.com/services/rest/?api_key=${api_key}&method=${method}&${params}"