You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

spypoint-api-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spypoint-api-wrapper

Node.js wrapper for the Spypoint game camera API

2.1.3
latest
npmnpm
Version published
Weekly downloads
28
2700%
Maintainers
1
Weekly downloads
 
Created
Source

spypoint-api-wrapper

A simple Node.js wrapper for the Spypoint game camera API

Getting Started

Initialize the Spypoint client

import SpypointClient from 'spypoint-api-wrapper'

const Spypoint = new SpypointClient()
await Spypoint.login('YOUR_EMAIL_OR_USERNAME', 'YOUR_PASSWORD')

Using within express.js routes and individual users

import SpypointClient from './spypoint.js'

// Send user crederntials to login route and set auth token on the cookie

router.post('/login', async (req, res) => {

  const Spypoint = new SpypointClient()
  const bearer = await Spypoint.login(req.body.email, req.body.password)
  res.cookie('authorization', bearer, {
    expire: '2100-01-01T00:00:00.000Z,
    httpOnly: process.env.NODE_ENV === 'production' ? true : false
  })
  res.send()

})

// Middleware to pass auth token for requestsg

const SpypointInit = (req, res, next) => {
  if (!req.cookies.authorization) throw Error('You need to login with valid credentials first!')
  req.Spypoint = new SpypointClient(req.cookies.authorization)
  next()
}


router.get('/', SpypointInit, (req, res) => {
  const cameras = await req.Spypoint.cameras()
  res.send(cameras)
})

API

Spypoint.login() ⇒ Promise.<string>

Returns: Promise.<string> - Bearer token used for authorization (this is automatically set and added to all requests)

Spypoint.cameras() ⇒ Promise.<Array>

Returns: Promise.<Array> - List of all available cameraIds

Spypoint.filters() ⇒ Promise.<Object>

Returns: Promise.<Object> - Object containing a property .species w/ list of all available filter tags

Spypoint.mostRecentPhotosByCamera() ⇒ Promise.<Array>

Returns: Promise.<Array> - List of most recent photo taken from each camera

Spypoint.photosByCamera(cameraId, [options]) ⇒ Promise.<Array>

Returns: Promise.<Array> - List of photos from an individual camera

ParamTypeDescription
cameraIdstringUnique identifier for the camera to request photos from
[options]ObjectOptions object
[options.tags]Array | stringArray of filter tag options or a single tag as a string
[options.limit]NumberMaximum number of results to return

Spypoint.queryAllPhotos([options]) ⇒ Promise.<Array>

Returns: Promise.<Array> - List of photo by individual camera

ParamTypeDescription
[options]ObjectOptions object
[options.tags]Array | stringArray of filter tag options or a single tag as a string
[options.limit]NumberMaximum number of results to return

Keywords

spypoint

FAQs

Package last updated on 23 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts