# gotify

> Gotify JS Client

Latest version **1.1.0** (published 2021-06-17) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install gotify
pnpm add gotify
yarn add gotify
bun add gotify
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-06-17 |
| First published | 2021-06-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Thomas Queste |
| Maintainers | tomsquest |
| Keywords | gotify |

## Links

- npm: https://www.npmjs.com/package/gotify
- Repository: https://github.com/tomsquest/gotify
- Homepage: https://github.com/tomsquest/gotify#readme
- Issues: https://github.com/tomsquest/gotify/issues
- npm.io page: https://npm.io/package/gotify

## Dependencies (1)

- [got](https://npm.io/package/got.md) 10.7.0

## Recent versions

- 1.1.0 (latest) — 2021-06-17
- 1.0.0 — 2021-06-06

## README

# Gotify JavaScript Client

<div align="center">

![Logo](doc/logo.png)

</div>

[![Version](https://img.shields.io/npm/v/gotify.svg?style=for-the-badge)](https://www.npmjs.com/package/gotify)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/tomsquest/gotify/check?style=for-the-badge)

## What is it

This module is a Node.js client for [Gotify](https://gotify.net/), a simple server for sending and receiving messages.

## Why

I needed a **Node.js** client to get instant notification on my Phone.

Actually, the [Gotify API](https://gotify.net/api-docs) for sending message is really simple. It is basically a POST request to the `/message` endpoint. This client makes it even easier and straightforward.

## Changelog

> See [CHANGELOG.md](CHANGELOG.md)

## Install

```sh
npm install gotify
```

## Usage

```js
const { gotify } = require("gotify");
// Typescript
// import { gotify } from "gotify";

await gotify({
  server: "http://gotify.example.com",
  app: "yourAppToken",
  title: "some title",
  message: "some msg",
  priority: 5,
});
```

Or, you can instantiate `Gotify` class:

```js
const { gotify } = require("gotify");
// Typescript
// import { gotify } from "gotify";

const client = new Gotify({
  server: "http://gotify.example.com",
});

await client.send({
  app: "yourAppToken",
  title: "some title",
  message: "some msg",
  priority: 5,
});
```

To add [message Extras](https://gotify.net/docs/msgextras), simply pass them (TypeScript should autocomplete the known extras):

```js
await gotify({
  server: server,
  app: app,
  title: "A Markdown message",
  message: `This is a **message** with the ![Gotify Logo](https://raw.githubusercontent.com/gotify/logo/master/gotify-logo-small.png)!`,
  priority: 5,
  // Extras are defined here https://gotify.net/docs/msgextras
  extras: {
    // Format message as markdown
    "client::display": {
      contentType: "text/markdown",
    },
    // Opens the URL on notification click.
    "client::notification": {
      click: { url: "https://github.com/gotify" },
    },
    // Opens the URL after the notification was delivered.
    // Only works when the gotify app is in focus (limitation of android)
    "android::action": {
      onReceive: { intentUrl: "https://gotify.net" },
    },
  },
});
```

## API

### Send message

Either use `gotify()` or instantiate `new Gotify()`.

Fields:

- `server` (required): the server you are using, eg. "http://gotify.example.com"
- `app` (required): this is the application token that you get when creating an application
- `message` (required): the message's title
- `title` (optional): the message's title
- `priority` (optional): the message's priority. On my Android phone, priority>=4 will trigger the notification **sound/vibrate**, less will just display the notification bubble.
- `extras` (optional): the message's extras as defined [in the documentation](https://gotify.net/docs/msgextras)

## TODO/MAYBE

- [ ] ? [Set Markdown with a flag: `markdown: true`](https://gotify.net/docs/msgextras#clientdisplay)
- [ ] ? Could specify the application token in the `Gotify` class to not pass it when sending a message
- [ ] ? Support for custom http client (put `got` as a peerDependency and provides example with node-fetch and axios)

---
_Source: https://npm.io/package/gotify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
