
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
A JavaScript wrapper library/SDK for the Splitwise API.
Created by Keri Warr because he 💖s Splitwise.
This package can be used with Node with version at least 8
.
Register your splitwise application here to get a client key and a client secret.
$ npm install --save splitwise
const { Splitwise } = require('splitwise');
const sw = new Splitwise({
clientKey: 'your key here',
clientSecret: 'your secret here',
});
sw.getCurrentUser().then(console.log);
In this example, we create a new expense from the current user, to the first listed user in the given group, with the same description as the first given expense.
const { Splitwise } = require('splitwise');
const sw = new Splitwise({
consumerKey: 'your key here',
consumerSecret: 'your secret here',
});
const groupID = '12345678';
Promise.all([
sw.getGroup({ groupID: groupID }),
sw.getExpenses({ groupID: groupID }),
sw.getCurrentUser(),
]).then(([group, expenses, me]) => sw.createDebt({
from: group.members[0].id,
to: me.id,
groupID: groupID,
description: expenses[0].description,
amount: 100,
}));
In order to know which parameters must or can be passed in to various methods, please refer to the original API documentation: http://dev.splitwise.com/dokuwiki/doku.php.
new Splitwise(options)
To the constructor you must pass in a consumerKey
and a consumerSecret
.
You may optionally pass in the following parameters: groupID
, userID
, expenseID
, and friendID
. They will be used by default for basic CRUD operations if you do not specify an ID. For example:
const sw = new Splitwise({
...
groupID: '12345678',
});
sw.getGroup().then(console.log);
For any of the API methods documented on Splitwise's website, you can use it by calling the camelcase named version of the endpiont on the splitwise object (i.e. remove_user_from_group
becomes sw.removeUserFromGroup()
).
For some group methods such as getGroup
you must pass in a groupID:
sw.getGroup({ groupID: '12345678' }).then(...);
For some expense methods, user methods, and friend methods, you must do the same.
Splitwise makes some important notes about their API that booleans, and nested parameters don't work. You don't need to worry about this. Instead of calling:
sw.createExpense({
users__0__user_id: '23456789',
users__1__users_id: '34567890',
payment: 0,
});
You make simply do:
sw.createExpense({
users: [
{ user_id: '23456789' },
{ user_id: '34567890' },
],
payment: false,
});
And on that note...
sw.createDebt()
The params that must be passed in to the create_expense
endpoint are a little obtuse, so there is provided this hepler method which can be used as follows:
sw.createDebt({
from: '23456789',
to: '34567890',
amount: 100,
description: 'yay!',
});
This package came about after I wrote a blog post about using this API.
This package is MIT licensed.
FAQs
A JavaScript SDK for the Splitwise API.
The npm package splitwise receives a total of 16 weekly downloads. As such, splitwise popularity was classified as not popular.
We found that splitwise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.