Blog

You’ve got a great API, and you’d like to easily help people get started with that API, by allowing them to quickly launch their first API call, from anywhere. Hmm… how could you do that? Well, let’s have a look at DHC! You can create a simple link or button in any web page, with some special JavaScript sauce, to let API consumers launch DHC with a pre-filled request.

If you look back at my Pi digits API from a couple months ago, you might have noticed this button:

If DHC isn’t installed in Chrome (as DHC is a Chrome extension), it’ll suggest you to install DHC. But if DHC is indeed installed, it’ll launch DHC with a pre-filled request, that you can directly try to send!

How to do the magic? You’ll need a bit of pixie dust in your HTML page:

a meta tag to make DHC aware of the fact you want to launch a request,

a bit of JavaScript to let your page communicate with the DHC Chrome extension,

and a JSON payload to represent the details of the request you want to open in DHC.

To learn more about how to open DHC from any web page, with custom requests, you can read some more details on the DHC documentation to get all the technical details.