Skip to content

DensityCo/demo-entry-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Entry Counter

A simple React application that displays an entry counter connected to a websocket. The app listens to a websocket and increments the counter whenever there is an entry event.

Features

  • Connect to Density API websocket to track space occupancy
  • Display entry count with retro flip animation
  • Reset button to reset the counter
  • Hideable sidebar drawer to observe raw websocket events
  • Space ID and API token configuration

Getting Started

Prerequisites

  • Node.js >= 16
  • npm >= 8

Installation

  1. Clone the repository
  2. Install dependencies
    npm install
    
  3. Start the development server
    npm start
    

Running with a Custom Port

By default, the app runs on port 3000. You can specify a different port using the standard PORT environment variable:

PORT=8080 npm start

Usage

  1. Enter your Space ID and API Token in the fields provided
  2. Click "Connect" to establish a websocket connection
  3. The counter will automatically increment when entries are detected
  4. Click "Reset" to reset the counter to zero
  5. Click the menu icon in the top-left to view raw websocket events

API Integration

This app connects to the Density API using the following endpoint:

POST https://api.density.io/v3/analytics/ws/space/{space_id}/occupancy

with an Authorization header containing your API key.

License

ISC

About

Demonstration of public-api websockets in a React App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors