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

@moneylion/engine-api

v1.3.1

Published

Interface to engine.tech API

Downloads

204

Readme

Engine API

This is a Javascript interface to the Engine API service.

Getting Started

Install the library

npm add @moneylion/engine-api

Request an authentication token and API endpoint from Engine.

Creating a Client Instance

Normally you won't have to create a client instance, but you can do so if you want to make a request that this library doesn't support.

import { Client } from "@moneylion/engine-api";

new Client(endpoint, authentication_token);

This provides get, post, and patch methods that accept a REST endpoint and a request body. The request body will be serialized to JSON before being sent. If you want to pass a body as a string or use a different HTTP method, use the request method.

client.request("/endpoint", "DELETE", "body as a string");

Creating a Lead

To create a lead, you can do the following:

import { Lead } from "@moneylion/engine-api";

new Lead(endpoint, authentication_token).create(lead);

This will return a promise that resolves with the UUID of the lead that was just created. It will not create a rate table yet. In order to create a rate table you can do the following:

import { Lead } from "@moneylion/engine-api";

new Lead(endpoint, authentication_token).getRateTable(lead);

This will return a promise that resolves with an AsyncRateTable. You can use the AsyncRateTable.resolve() method to turn it into a real RateTable. You can also use getRateTableBlocking which will resolve with a RateTable, but you will potentially spend longer waiting for network requests.

You can do the lead creation and rate table fetch in one step using the createAndGetRateTable and createAndGetRateTableBlocking methods.

Updating a Lead

To update a lead, you can do the following:

import { Lead } from "@moneylion/engine-api";

new Lead(endpoint, authentication_token).update(leadUuid, updatedLead);

This returns a promise but will not resolve with a rate table and will instead resolve the lead UUID back to you when it finishes.

Rate Tables

Rate tables are returned when you create a lead. If you would like to retrieve a rate table manually you can request it by its UUID.

import { AsyncRateTable } from "@moneylion/engine-api";

new AsyncRateTable({ uuid: rateTableUuid, host: endpoint, api_token: authentication_token }).resolve();

// You can also pass a pre-created client instead of endpoint and token
new AsyncRateTable({ uuid: rateTableUuid, client: client }).resolve();

// You can also pass a RateTable object instead of a uuid.
new AsyncRateTable({ rateTable: rateTable, client: client }).resolve();

For Contributors

This is a relatively normal NPM and Typescript project.

  1. npm install to install dependencies
  2. npm run build to build the project
  3. npm test to run the tests

Publishing to NPM

Run the following steps to publish the library to NPM.

  1. Update the version number in package.json. Commit this change.
  2. npm run build - This will run Typescript to compile the Javascript.
  3. npm publish --access=public. This will publish the library.