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 🙏

© 2024 – Pkg Stats / Ryan Hefner

fritz-box

v1.2.1

Published

FRITZ!Box API

Downloads

17

Readme

Examples

Basic

import FritzBox from 'fritz-box'

const box = new FritzBox({
	host: 'fritz.box',
	password: '...',
	username: '...'
})

const run = async () => {
	await box.getSession()
	const settings = await box.getGuestWLAN()
	settings.active = true
	settings.ssid = 'Example!'
	await box.setGuestWLAN(settings)
	console.log(await box.overview())
}

run()

IFTTT Notify

This will activate the guest WLAN and emit a IFTTT Maker channel notify event. If you create the fitting IFTTT recipe, this snippet should send you the WLAN password right to your smartphone.

import FritzBox from 'fritz-box'
import IFTTT from 'maker-ifttt'

const box = new FritzBox({
	host: 'fritz.box',
	password: '...',
	username: '...'
})
const maker = new IFTTT('IFTTT_MAKER_TOKEN')

const run = async () => {
	// generate a random 8-digit hex password
	const newPassword = crypto.randomBytes(4).toString('hex');

	// sign-in
	await box.getSession()

	// get current guest WLAN settings
	const settings = await box.getGuestWLAN()

	// set new password & turn on guest WLAN
	settings.key = newPassword
	settings.active = true
	await box.setGuestWLAN(settings)

	// send a message to IFTTT (optional)
	maker.triggerEvent('notify', `Guest WLAN password is ${password}.`, response =>
		response.on('data', chunk =>
			console.info('Response: ' + chunk)
		)
	)
}

run()

Installation

or

API

default class FritzBox <>

({ host = 'fritz.box', password: String, username: String }: Object): FritzBox

Creates a new FritzBox with the given parameters.

const box = new FritzBox({
	host: 'fritz.box',
	password: '...',
	username: '...'
});

box.getSession

(): Promise

Attempts to log in and fetches a session ID.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	// fritz-box is now ready for use
})()

box.getGuestWLAN

(): Promise

Fetches the guest WLAN configuration from the FRITZ!Box.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	const settings = await box.getGuestWLAN()
})()

box.setGuestWLAN

(settings: Object): Promise

Applies the (modified) settings object.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	await box.setGuestWLAN(settings)
})()

box.overview

(): Promise

Returns the data contained in the overview tab of the FRITZ!Box user interface.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	console.log(await box.overview())
})()

box.getDeviceDetails

(id: String): Promise

Gathers more information about a specific device.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	console.log(await box.getDeviceDetails('some-id'))
})()

box.getLog

(type = 'all' : String): Promise

Returns log entries. Supported types: 'all', 'system', 'internet', 'wlan', 'usb'.

;(async () => {
	const box = new FritzBox(/* ... */)
	await box.getSession()
	console.log(await box.getLog())
})()

Disclaimer

Tested in FRITZ!OS 6.92 on a FRITZ!Box 7590.

FRITZ!Box and FRITZ!OS are registered trademarks of AVM. This project does not grant you any permissions to use them.

History

  • 1.2.0

    • add getLog
    • improve documentation
  • 1.1.0

    • directly throw errors
    • add getDeviceDetails