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

spond-api

v1.0.3

Published

Spond API Client for Node.js

Downloads

11

Readme

Spond Package

This package provides a unofficial TypeScript class Spond that allows you to interact with the Spond API. It includes functionalities for logging in, fetching groups and events, managing chats, and more. This package was inspired by Spond, a python package, which extracted the Spond API calls, which this Node.js package is using aswell. This package is basically just a translation of Spond.

Installation

npm install spond-api

Usage

Importing the Module

import { Spond } from 'spond-api';

Creating an Instance

Create an instance of the Spond class by providing your Spond username and password.

const spond = new Spond('your_username', 'your_password');

Methods

Below are the available methods and their usage.

loginChat()

Logs in to the chat system and sets the chatUrl and auth properties.

await spond.loginChat();

getGroups(params: GetGroupsParams = {})

Fetches all groups.

  • params (optional): An object with optional properties.
const groups = await spond.getGroups();

getGroup(params: { uid: string })

Fetches a specific group by its unique identifier.

  • params:
    • uid: The unique identifier of the group.
const group = await spond.getGroup({ uid: 'group_id' });

getPerson(params: GetPersonParams)

Fetches a person by their identifier.

  • params:
    • user: The user's identifier.
const person = await spond.getPerson({ user: 'user_id' });

getMessages()

Fetches messages from the chat system.

const messages = await spond.getMessages();

continueChat(params: { chatId: string, text: string })

Continues a chat by sending a message.

  • params:
    • chatId: The chat ID.
    • text: The message text.
const response = await spond.continueChat({ chatId: 'chat_id', text: 'Hello!' });

sendMessage(params: { text: string, user?: string, groupUid?: string, chatId?: string })

Sends a message. If chatId is provided, continues the chat, otherwise sends a new message to a user in a group.

  • params:
    • text: The message text.
    • user (optional): The user ID.
    • groupUid (optional): The group ID.
    • chatId (optional): The chat ID.
const response = await spond.sendMessage({ text: 'Hello!', user: 'user_id', groupUid: 'group_id' });

getEvents(params: GetEventsParams = {})

Fetches events.

  • params (optional): An object with optional properties:
    • groupId: The group ID.
    • subgroupId: The subgroup ID.
    • includeScheduled: Whether to include scheduled events.
    • maxEnd: The maximum end date.
    • minEnd: The minimum end date.
    • maxStart: The maximum start date.
    • minStart: The minimum start date.
    • maxEvents: The maximum number of events to fetch.
const events = await spond.getEvents({ groupId: 'group_id', maxEvents: 50 });

getEvent(params: { uid: string })

Fetches a specific event by its unique identifier.

  • params:
    • uid: The unique identifier of the event.
const event = await spond.getEvent({ uid: 'event_id' });

updateEvent(params: UpdateEventParams)

Updates an event with the provided data.

  • params:
    • uid: The unique identifier of the event.
    • updates: An object containing the updates.
const updatedEvent = await spond.updateEvent({ uid: 'event_id', updates: { heading: 'New Heading' } });

getEventAttendanceXlsx(params: { uid: string })

Fetches the attendance data for an event in XLSX format.

  • params:
    • uid: The unique identifier of the event.
const attendanceXlsx = await spond.getEventAttendanceXlsx({ uid: 'event_id' });

changeResponse(params: { uid: string, user: string, payload: any })

Changes the response of a user for a specific event.

  • params:
    • uid: The unique identifier of the event.
    • user: The user ID.
    • payload: The payload containing the new response.
const response = await spond.changeResponse({ uid: 'event_id', user: 'user_id', payload: { status: 'going' } });

Error Handling

The Spond class methods throw errors if the API calls fail. Ensure to use try...catch blocks to handle these errors gracefully.

try {
    const groups = await spond.getGroups();
} catch (error) {
    console.error('Failed to fetch groups:', error);
}

License

This project is licensed under the MIT License.