Skip to main content

Webhouk SDK

Let's recap everything we did in Quick Start:

  • Created a Channel
  • Created an Endpoint
  • Sent a Message to the Channel
  • View the Log of the Message we've sent

Let's do the same, but with code!

Before we start#

Head over to your Webhouk Account Page (https://dashboard.webhouk.com/account) and grab API Key, it should look like this:

api_3uEes2ff5_KaSBE5T8Xwc

Install Webhouk SDK#

via npm:

npm i webhouk

or yarn:

yarn add webhouk
tip

Webhouk API is Graphql. Checkout Graphiql Playground at https://api.webhouk.com/

Create Channel, Endpoint, and Send Message#

import {API, Webhouk} from 'webhouk'
const apiKey = process.env.WEBHOUK_API_KEY
const api = new API(apiKey)
const description = 'Test description'
const name = 'Test name'
const channel = await api.addChannel({name, description})
const url = 'https://my-test-website.com/hook'
const endpoint = await api.addEndpoint({
name,
description,
channelId: channel.id,
url,
})
const data = JSON.stringify({name: "John", age: 21})
const message = await api.sendMessage({
channelId: channel.id,
eventType,
eventId,
data
})
const messageLog = await api.messageLogs({
messageId: message.id,
channelId: channel.id,
})
console.log(messageLog) // message log

We are actively developing API and would like to hear your feedback. Please mail us to [email protected]!