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

loriapi

v1.0.8

Published

A simple library for fetching information from Loritta, a popular Discord bot made by the Brazilian developer MrPowerGamerBR.

Downloads

502

Readme

LoriApi Lori_Point

A powerful, straightforward library to interact with the Loritta API, a well-known Discord bot developed by Brazilian developer MrPowerGamerBR power_lori. With LoriApi, you can easily retrieve detailed user data and transaction history directly from the Loritta API.

Installation

Install LoriApi via npm:

npm install loriapi

Usage

Importing the Library

Import the LoriApi module into your project:

import LoriApi from "loriapi";

Initialization

To initialize the LoriApi class, create an instance with your Loritta API key. Ensure your API key begins with lorixp_ and has the correct length (51-52 characters), or the instance will not initialize properly.

const api = new LoriApi({ loriKey: "lorixp_your_key_here" });

Fetching User Data

Use the getUserData method to retrieve comprehensive information about a user, including optional metadata in the headers. This method returns a combined object with both the data and the relevant header fields.

api
  .getUserData("123170274651668480")
  .then((userData) => {
    console.log(userData.id); // User ID
    console.log(userData.sonhos); // User "Dreams" count
    console.log(userData.gender); // User's gender
    console.log(userData.LorittaCluster); // Access to response headers
  })
  .catch((error) => {
    console.error("Error fetching user data:", error.message);
  });

Example Response from getUserData

A typical response from getUserData provides fields for both user data and header metadata:

{
  "id": "123170274651668480",
  "xp": 6283483,
  "sonhos": 19613336,
  "aboutMe": "\"She said 'rawr x3', so it's true love at first sight\"",
  "gender": "MALE",
  "emojiFightEmoji": "<:lori_sip:1167125644296069160>",
  "LorittaCluster": "Loritta Cluster 1 (Catalyst)",
  "LorittaTokenCreator": "123170274651668480",
  "LorittaTokenUser": "123170274651668480"
}

Fetching User Transactions

Retrieve a user's transaction history with the getUserDataTransactions method. This method allows for optional filters by transaction type and date range.

Example Usage of getUserDataTransactions

api
  .getUserDataTransactions(
    "123170274651668480",
    ["PAYMENT", "DAILY_REWARD"],
    "2024-01-01T00:00:00.000Z",
    "2024-12-31T23:59:59.999Z"
  )
  .then((transactionData) => {
    console.log(transactionData.transactions); // Array of transactions
    console.log(transactionData.paging); // Paging information
    console.log(transactionData.headers); // Header metadata
  })
  .catch((error) => {
    console.error("Error fetching user transactions:", error.message);
  });

Parameters for getUserDataTransactions

  • userId: The Discord user ID.
  • transactionTypes (optional): An array of specific transaction types (e.g., ["PAYMENT", "EVENTS"]).
  • beforeDate (optional): Sets an end date (ISO string or Unix timestamp).
  • afterDate (optional): Sets a start date (ISO string or Unix timestamp).

List of Valid Transaction Types

The following transaction types are supported:

  • "PAYMENT", "DAILY_REWARD", "COINFLIP_BET", "COINFLIP_BET_GLOBAL", "EMOJI_FIGHT_BET", "RAFFLE", "HOME_BROKER", "SHIP_EFFECT", "SPARKLYPOWER_LSX", "SONHOS_BUNDLE_PURCHASE", "INACTIVE_DAILY_TAX", "DIVINE_INTERVENTION", "BOT_VOTE", "POWERSTREAM", "EVENTS", "LORI_COOL_CARDS", "LORITTA_ITEM_SHOP", "BOM_DIA_E_CIA", "GARTICOS"

API Reference

LoriApi

Constructor

new LoriApi(options: ApiOptions)
  • options: An object containing the loriKey string, which is your Loritta API key.

Methods

  • getUserData(userId: string): Promise<UserData & UserHeaders>
    Fetches user data, returning combined data fields and headers.
  • getUserDataTransactions(userId: string, transactionTypes?: string[], beforeDate?: string | number, afterDate?: string | number): Promise<TransactionData>
    Fetches user transactions with optional filters for transaction types and date ranges.

Types

ApiOptions

Initialization options for LoriApi:

type ApiOptions = {
  loriKey: string;
};

UserData

Structure of the data returned by getUserData:

interface UserData {
  id: string;
  xp: number;
  sonhos: number;
  aboutMe: string;
  gender: string;
  emojiFightEmoji: string;
}

UserHeaders

Headers returned in the getUserData response:

interface UserHeaders {
  LorittaCluster?: string;
  LorittaTokenCreator?: string;
  LorittaTokenUser?: string;
}

TransactionData

Structure for the data returned by getUserDataTransactions:

interface TransactionData {
  transactions: Array<any>;
  headers: UserHeaders;
  paging: any;
}

Error Handling

If the loriKey is invalid, the process will terminate with an error message indicating the invalid key format. Errors encountered during API calls will be thrown with a descriptive error message for debugging.