Query Planetlabs API from SlackHQ
Fri 23 March 2018Lately I’ve been looking into microservices and webhooks, and along the way made a slash command in Slack that will query the Planet image catalog and return matching image IDs. Here’s how:
1.) Make yourself a microservice. I used hook.io because it’s free, and I’m cheap. The code I used is here. Basically, it receives a request from Slack (including your api key, item type, asset type, cloud cover limit, and bounding box), formats it into a Planet-friendly query, sends the request to Planet, and returns the response to Slack when it’s ready.
2.) Create a new slash command in Slack. Make sure you set the request URL to your microservice above. I called my slash command ‘/planetcatalog’, but you can use whatever you want.
3.) Install your slash command in Slack.
4.) Run the command, like so (this isn’t a real api key – you’ll need your own):
/planetcatalog a44eb36fe3854f1db1ebXXXdff1a1a3f | PSScene4Band | analytic_sr | 0.1 | {u'type': u'Polygon', u'coordinates': [[[-118.364429, 34.0597], [-118.364429, 34.061552], [-118.362153, 34.061552], [-118.362153, 34.0597], [-118.364429, 34.0597]]]}
The result should be a list of image IDs. Enjoy!