npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fcm-rest-api

v1.0.7

Published

FCM REST API

Downloads

62

Readme

fcm-rest-api

A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM). Supports android, iOS and Web push, including topic messages, and topic subscribe/unsubscribe functionalities.
Additionally it also keeps the callback behavior for the new firebase messaging service.

Installation

Via [npm][1]:

$ npm install fcm-rest-api

Usage

There are 3 APIs for FCM Push Functionality:

FCM REST APIs

  1. Send Push Message To Android/IOS/Web/Topic
  2. Subscribe Topic For FCM Push
  3. UnSubscribe Topic To Stop FCM Push

CONFIGURATIONS

    const fcm = require('fcm-rest-api')
    
    var serverKey = require('path/to/privatekey.json') //put the generated private key path here  
	

SEND PUSH MESSAGE TO ANDROID/IOS/WEB

	
	var platfrom = 'android/ios/web';//VALID PLATFORMS
	
	var notificationObj: {
		title: 'Title of your push notification', 
		body: 'Body of your push notification', 
		click_action: 'Click Action Url', 
		image: 'Image Url', 
		badge: 'Badge Count'
	};
	
	var additionalObj: {
		key1: 'value1', 
		key2: 'value2' 
	};
    
    fcm.sendPushToTokens(serverKey, tokens, notificationObj, additionalObj, 'android')
	.then(json => {
		resolve(json);
	})
	.catch((err) => {
		reject(err);
	});

SEND PUSH MESSAGE TO TOPIC

	
	var topic = "topic_name_here";
	
	var notificationObj: {
		title: 'Title of your push notification', 
		body: 'Body of your push notification', 
		click_action: 'Click Action Url', 
		image: 'Image Url',  
		badge: 'Badge Count'
	};
	
	var additionalObj: {
		key1: 'value1', 
		key2: 'value2' 
	};
    
    fcm.sendPushToTopic(serverKey, topic, notificationObj, additionalObj)
	.then(json => {
		resolve(json);
	})
	.catch((err) => {
		reject(err);
	});

SUBSCRIBE TO TOPIC

   
	var topic = "topic_name_here";
    
    fcm.subscribeToTopic(serverKey, tokens, topic)
	.then(json => {
		resolve(json);
	})
	.catch((err) => {
		reject(err);
	});

UNSUBSCRIBE FROM TOPIC

	
	var topic = "topic_name_here";
    
    fcm.unSubscribeToTopic(serverKey, tokens, topic)
	.then(json => {
		resolve(json);
	})
	.catch((err) => {
		reject(err);
	});

UPDATES

1-> Version 1.0.0 -> Initial Setup
2-> Version 1.0.1 -> Web Push Click Action Issue Fixed
3-> Version 1.0.3 -> Minor code formatting Issue Fixed
4-> Version 1.0.4 -> Send Image in Push Notification 
5-> Version 1.0.5 -> Send Image in Push Notification 
6-> Version 1.0.6 -> Send Data To Topic Push Notification Issue Fixed
7-> Version 1.0.7 -> Node Fetch package updated