Query Planetlabs API from SlackHQ

Lately 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!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s