Gotify Client

February 3, 2024 Β· View on GitHub

gotify-client

Gotify Client

npm version npm downloads License

Full-featured HTTP client to work with Gotify API.

Table of Contents

🎯 Features

  • πŸ”₯ Code gen. The client is fully compliant with the official documentation.
  • πŸ‘Œ Slim. Zero dependencies.
  • ✨ Runner. Browser and Node support.
  • 🌐 Custom Http. If you need a custom http client, you can swap it out.
  • 🌳 Tree shaking. Only use what you need.
  • πŸͺ„️ TypeScript. The library is entirely made in typescript

✨ Installation

# Using pnpm
pnpm add gotify-client -D

# Using yarn
yarn add gotify-client -D

# Using npm
npm install gotify-client -D

⚑ Usage

πŸ—ΊοΈ Mapping version

Gotify ClientGotify Server
0.4.02.4.0

πŸš€ Base

import { GotifyClient } from 'gotify-client'

const client = new GotifyClient('http://gotify.home', {
    // You must specify at least 1 key
    app: 'app_api_key',
    client: 'client_api_key'
})

const message = await gotify.message.createMessage({
  message: "Test message!"
})

βš™οΈ Configuration

To execute requests, you need to specify a link to the host gotify, as well as pass api keys.

In Gotify there are two token types:

  • app: an application is something that sends messages.
  • client: a client is something that receives message and manages stuff like creating new tokens or delete messages.
constructor(host: string, authKeys: {
  app?: string
  client?: string
})

πŸ€– API

The source documentation is fully described in swagger on the official website.

ApplicationApi

MethodDescriptionHttp request
getAppsReturn all applications.GET /application
createAppCreate an application.POST /application
updateApplicationUpdate an application.PUT /application/${id}
deleteAppDelete an application.DELETE /application/${id}
uploadAppImageUpload an image for an application.POST /application/${id}/image
removeAppImageDeletes an image of an application.DELETE /application/${id}/image
getAppMessagesReturn all messages from a specific application.GET /application/${id}/message
deleteAppMessagesDelete all messages from a specific application.DELETE /application/${id}/message

ClientApi

MethodDescriptionHttp request
getClientsReturn all clients.GET /client
createClientCreate a client.POST /client
updateClientUpdate a client.PUT /client/${id}
deleteClientDelete a client.DELETE /client/${id}

CurrentApi

MethodDescriptionHttp request
currentUserReturn the current user.GET /current/user
updateCurrentUserUpdate the password of the current user.POST /current/user/password

HealthApi

MethodDescriptionHttp request
getHealthGet health information.GET /health

MessageApi

MethodDescriptionHttp request
getMessagesReturn all messages.GET /message
createMessageCreate a message.POST /message
deleteMessagesDelete all messages.DELETE /message
deleteMessageDeletes a message with an id.DELETE /message/${id}

PluginApi

MethodDescriptionHttp request
getPluginsReturn all plugins.GET /plugin
getPluginConfigGet YAML configuration for Configurer plugin.GET /plugin/${id}/config
updatePluginConfigUpdate YAML configuration for Configurer plugin.POST /plugin/${id}/config
disablePluginDisable a plugin.POST /plugin/${id}/disable
getPluginDisplayGet display info for a Displayer plugin.GET /plugin/${id}/display
enablePluginEnable a plugin.POST /plugin/${id}/enable

StreamApi

MethodDescriptionHttp request
streamMessagesWebsocket, return newly created messages.GET /stream

UserApi

MethodDescriptionHttp request
getUsersReturn all users.GET /user
createUserCreate a user.POST /user
getUserGet a user.GET /user/${id}
updateUserUpdate a user.POST /user/${id}
deleteUserDeletes a user.DELETE /user/${id}

VersionApi

MethodDescriptionHttp request
getVersionGet version information.GET /version

⚑ Advanced

πŸͺ„ Custom client

import { MessageApi } from 'gotify-client'

const httpClient = new CustomHttpClient()
const messageApi = new MessageApi(httpClient)

const message = await messageApi.createMessage({
    message: "Test message!"
})

πŸ“„ License

This template was created under the MIT License.