Access a direct feed of your tips with WebSockets.
Unofficial package for Pally.gg. | Pally.gg's Developer Documentation
⚠️ The WebSockets feed is currently in Beta and subject to change.
npm install pally.ggAvailable as Pally on the global object.
<script src="https://unpkg.com/pally.gg/dist/pally.js"></script>
or
import Pally from 'https://unpkg.com/pally.gg';
const client = new Pally.Client({ auth: 'YOUR_API_KEY' });You will need an API key with the events:read scope (default) to access the Pally.gg API.
Get your API key.
import Pally from 'pally.gg';
const client = new Pally.Client({ auth: 'YOUR_API_KEY' });
client.connect();
client.on('connect', () => {
setTimeout(() => client.sendTest(), 500);
});
client.on('campaigntip.notify', (campaignTip, page) => {
const { grossAmountInCents, displayName, message } = campaignTip;
const amount = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' })
.format(grossAmountInCents / 100);
console.log(`New tip! ${amount} from ${displayName}: ${message}`);
});Enables connecting to the Pally.gg WebSockets feed.
The Client extends a basic, typed EventEmitter.
- Required
Your API key. Get your API key.
- Default:
'firehose'
The type of channel to connect to from the options.
'firehose'is the default and is used for general tips.'activity-feed'is used for tips on a specific page.
- Required: When
channelis'activity-feed'
The room to connect to from the options. This is the slug of the page you want to receive tips for.
Connect to the WebSockets feed.
Disconnect from the WebSockets feed.
Ask the server to echo a test message. This is useful for testing your connection and events. The
'campaigntip.notify' event will be emitted with a test payload. The payload will be the same each time. The tip ID
will be 'TEST'.
Alternatively, you can press the "Replay Alert" button in the Pally.gg activity feed.
Used with client.on(eventName, (/* ... */) => void) to listen for events.
Emitted when the client has successfully connected to the WebSockets feed.
Emitted when the connection has been closed.
Emitted when the client is about to attempt to reconnect.
Emitted when a socket error occurred.
Emitted when a pong is received from the server. The latencyMs is the time in milliseconds it took to receive the pong
from the server.
Emitted when a new tip has been received. The campaignTip includes details about the tip, and the page includes
details about the page the tip was received on.
Your API key. Required.
The channel to connect to.
'firehose'- The firehose feed sends all tips for all pages you own. Default.'activity-feed'- The activity feed sends all tips for a specific page you own or have access to.
The specific activity feed "slug" to listen to. This is only required if the channel is set to `'activity-feed', otherwise it is ignored.
Options for keepalive.
The interval in seconds at which to send a ping to the server.
The number of seconds to wait for a pong response before closing the connection and reconnecting.
The unique identifier for the tip.
The date and time the tip was created.
The date and time the tip was last updated.
The gross amount of the tip in cents.
The net amount of the tip in cents.
The processing fee of the tip in cents.
The name of the tipper.
The message attached to the tip.
The unique identifier for the page.
The slug of the page.
The title of the page.
The URL of the page.