Introduction

Tugboat API Documentation

Web Sockets

  • The Tugboat API works over web sockets

Authentication

After the web socket connects, and before any API calls can be made, the client must first authenticate. This is done by sending an "authenticate" event with the API key as a payload. The callback will provide err, authkey, and admin values. If authentication is successful, err === null, and authkey contains a token that must be resubmitted with every API call. The admin flag is set to true if the API key used to authenticate as administrative privileges.

socket.emit('authenticate', { key: API_KEY }, (err, authkey, admin) => {
    // Use the returned authkey for other API calls
    socket.emit('tugboat', 'previews', 'list', { authkey }, (err, previews) => {
        console.log(previews);
    });
});

Administrative users can impersonate other users by substituting the authkey parameter with the ID of that user's API key

socket.emit('authenticate', { key: API_KEY }, (err, authkey, admin) => {
    // Impersonate another user
    if (admin) {
        socket.emit(
            'tugboat',
            'previews',
            'list',
            { authkey: '12345' },
            (err, previews) => {
                console.log(previews);
            }
        );
    }
});

Preview tokens can be used to get read-only access to that preview and its services.

socket.emit('authenticate', { key: PREVIEW_TOKEN }, (err, token) => {
    // Use the token for other API calls
    socket.emit(
        'tugboat',
        'previews',
        'list',
        { token, preview: ID },
        (err, preview) => {
            console.log(preview);
        }
    );
});

results matching ""

    No results matching ""