<commit_before># onesignal-node      

<p align="center">
  <a href="https://www.npmjs.com/package/onesignal-node">
    <img src="https://img.shields.io/npm/v/onesignal-node.svg" alt="Dependency Status" />
  </a>
  <a href="https://www.npmjs.com/package/onesignal-node">
    <img src="https://img.shields.io/npm/dm/onesignal-node.svg" alt="Download Count" />
  </a>
  <a href="https://circleci.com/gh/zeyneloz/onesignal-node">
    <img src="https://circleci.com/gh/zeyneloz/onesignal-node/tree/v3.x.svg?style=shield" alt="Build Status" />
  </a>
  <a href="https://snyk.io/test/github/zeyneloz/onesignal-node?targetFile=package.json">
    <img src="https://snyk.io/test/github/zeyneloz/onesignal-node/badge.svg?targetFile=package.json" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/zeyneloz/onesignal-node?targetFile=package.json" style="max-width:100%;">
  </a>
  <a href="https://codecov.io/gh/zeyneloz/onesignal-node">
    <img src="https://codecov.io/gh/zeyneloz/onesignal-node/branch/master/graph/badge.svg" />
  </a>
</p>
<br>

A Node.js client library for [OneSignal](https://onesignal.com/) API.  
**IMPORTANT:** This documentation belongs to v3.x.x which has no backward compatibility.
Please see [this page](https://github.com/zeyneloz/onesignal-node/tree/v2.x) for v2.x.x.  
      
## Table of Contents      
* [Overview](#overview)
* [Installation](#installation)      
* [Usage](#usage)        
  * [Client Types](#client-types)
  * [Creating Client](#creating-client)      
  * [Create notification](#create-notification)      
  * [Cancel notification](#cancel-notification)      
  * [View notifications](#view-notifications)      
  * [View notification](#view-notification)      
  * [View apps](#view-apps)      
  * [Create an app](#create-an-app)      
  * [Update an app](#update-an-app)      
  * [View devices](#view-devices)      
  * [View device](#view-device)      
  * [Add a device](#add-a-device)      
  * [Edit a device](#edit-a-device)
  * [Edit tags with external user id](#edit-tags-with-external-user-id)
  * [New session](#new-session)  
  * [New purchase](#new-purchase)  
  * [Increment Session Length](#increment-session-length)  
  * [CSV Export](#csv-export)        
  * [Identity verification](#identity-verification)      
* [Tests](#tests)
* [Contributing](#contributing)
      

## Overview  

This is a wrapper library over [OneSignal REST API](https://documentation.onesignal.com/reference). You can create notifications,
view apps, edit a device and all other actions you can take on OneSignal REST API.

## Installation      
      
```      
npm install onesignal-node --save      
```      

## Usage
      
``` js      
const OneSignal = require('onesignal-node');    
```      

### Client Types:

For all the actions that require your OneSignal app id and app api key, you should use `OneSignal.Client`.
Sample actions: create notification, add device, csv export, create segment...

``` js      
const client = new OneSignal.Client('appId', 'apiKey');
``` 

For all the actions that require your User Auth Key you should use `OneSignal.UserClient`.
Sample actions: view apps, update an app, create an app...

``` js      
const userClient = new OneSignal.UserClient('userAuthKey');
```      
      
### Creating client      

You can create a `Client` object as shown below. It requires two parameters: `appId` and `apiKey`, which you can find them on
your applications page on OneSignal dashboard.  

There is also an optional parameter called `options`. You can set OneSignal rest api endpoint if you wish to using options.
By default the library uses `https://onesignal.com/api/v1` for api endpoint.
  
```js      
// With default options
const client = new OneSignal.Client('appId', 'apiKey');

// With custom API endpoint<commit_msg>Add ts style import to documentation (#65)<commit_after># onesignal-node      

<p align="center">
  <a href="https://www.npmjs.com/package/onesignal-node">
    <img src="https://img.shields.io/npm/v/onesignal-node.svg" alt="Dependency Status" />
  </a>
  <a href="https://www.npmjs.com/package/onesignal-node">
    <img src="https://img.shields.io/npm/dm/onesignal-node.svg" alt="Download Count" />
  </a>
  <a href="https://circleci.com/gh/zeyneloz/onesignal-node">
    <img src="https://circleci.com/gh/zeyneloz/onesignal-node/tree/v3.x.svg?style=shield" alt="Build Status" />
  </a>
  <a href="https://snyk.io/test/github/zeyneloz/onesignal-node?targetFile=package.json">
    <img src="https://snyk.io/test/github/zeyneloz/onesignal-node/badge.svg?targetFile=package.json" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/zeyneloz/onesignal-node?targetFile=package.json" style="max-width:100%;">
  </a>
  <a href="https://codecov.io/gh/zeyneloz/onesignal-node">
    <img src="https://codecov.io/gh/zeyneloz/onesignal-node/branch/master/graph/badge.svg" />
  </a>
</p>
<br>

A Node.js client library for [OneSignal](https://onesignal.com/) API.  
**IMPORTANT:** This documentation belongs to v3.x.x which has no backward compatibility.
Please see [this page](https://github.com/zeyneloz/onesignal-node/tree/v2.x) for v2.x.x.  
      
## Table of Contents      
* [Overview](#overview)
* [Installation](#installation)      
* [Usage](#usage)        
  * [Client Types](#client-types)
  * [Creating Client](#creating-client)      
  * [Create notification](#create-notification)      
  * [Cancel notification](#cancel-notification)      
  * [View notifications](#view-notifications)      
  * [View notification](#view-notification)      
  * [View apps](#view-apps)      
  * [Create an app](#create-an-app)      
  * [Update an app](#update-an-app)      
  * [View devices](#view-devices)      
  * [View device](#view-device)      
  * [Add a device](#add-a-device)      
  * [Edit a device](#edit-a-device)
  * [Edit tags with external user id](#edit-tags-with-external-user-id)
  * [New session](#new-session)  
  * [New purchase](#new-purchase)  
  * [Increment Session Length](#increment-session-length)  
  * [CSV Export](#csv-export)        
  * [Identity verification](#identity-verification)      
* [Tests](#tests)
* [Contributing](#contributing)
      

## Overview  

This is a wrapper library over [OneSignal REST API](https://documentation.onesignal.com/reference). You can create notifications,
view apps, edit a device and all other actions you can take on OneSignal REST API.

## Installation      
      
```      
npm install onesignal-node --save      
```      

## Usage
      
``` js      
const OneSignal = require('onesignal-node');    
```      
OR
``` js      
import * as OneSignal from 'onesignal-node';  
```

### Client Types:

For all the actions that require your OneSignal app id and app api key, you should use `OneSignal.Client`.
Sample actions: create notification, add device, csv export, create segment...

``` js      
const client = new OneSignal.Client('appId', 'apiKey');
``` 

For all the actions that require your User Auth Key you should use `OneSignal.UserClient`.
Sample actions: view apps, update an app, create an app...

``` js      
const userClient = new OneSignal.UserClient('userAuthKey');
```      
      
### Creating client      

You can create a `Client` object as shown below. It requires two parameters: `appId` and `apiKey`, which you can find them on
your applications page on OneSignal dashboard.  

There is also an optional parameter called `options`. You can set OneSignal rest api endpoint if you wish to using options.
By default the library uses `https://onesignal.com/api/v1` for api endpoint.
  
```js      
// With default options
const client = new OneSignal.Client('appId', 'apiKey');

// With custom API endpoint
{'fraction_non_alphanumeric': 0.15027110766847404, 'fraction_numerical': 0.0023237800154918666, 'mean_word_length': 3.411731207289294, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 30, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4054099', 'n_tokens_mistral': 2576, 'n_tokens_neox': 2444, 'n_words': 608}