feature request: open API
It would be wonderful with an API to integrate with other system(s). It would also be wonderful if the API was easily browsable like https://en.wikipedia.org/wiki/OpenAPI_Specification
My use case is this: I frequent a community where we cook and eat together. We want to do monthly clearing based on the number of times we each participated and the individual expenses we had for cooking. Tracking of participation is done in other system(s). If spliit had an API we could build automation and save man-hours and human errors transferring the information. I know of at least 6 communities in my region that share my situation.
This feature may come with some strings attached like splitting front and backend, adding an authentication layer to avoid robots, ...
Thank you guys for a beautiful and simple app
This would probably be better implemented as a separate application with REST endpoints that directly manipulate the database. Self-hosting people could then install this alongside the app, pointing to the same database
I wouldn't necessarily be comfortable with this being available for the public website either.
It would be really useful for a mobile App
Perhaps we can write something that gives access over rest to the functions here? https://github.com/spliit-app/spliit/blob/main/src/lib/api.ts
Just a way to create access tokens, then you can call the already existing api calls?
This would probably be better implemented as a separate application with REST endpoints that directly manipulate the database. Self-hosting people could then install this alongside the app, pointing to the same database
I wouldn't necessarily be comfortable with this being available for the public website either.
Wouldn't every change regarding functions interacting with the database need to be implemented twice? Once for the Spliit app itself and once for the REST application? And what would happen if these different implementations don't align?
I think the requirements for the API have to be collected first.
For a mobile app a way of "sync" would be helpful/good but increases complexity quite a lot. That is a properly a different API use case as @jensfriisnielsen has in mind.
Maybe you could write what kind of endpoints you need first and then one could try to figure out the rest.
I also want to use an API, not only to create an app (I need offline support to add pictures etc) but also to extract expenses done during travel trips and present them in the format asked by my organization.
In term of API, one may want to look at: https://ihatemoney.readthedocs.io/en/latest/api.html That has a clear and simple API. Once we have one, we can maybe integrate it to moneybuster that already supports two apps (ihatemoney and nextcloud cospend)
For a mobile app a way of "sync" would be helpful/good but increases complexity quite a lot.
I also don't see why synchronisation is really required in the API. An app can just implement sync by keeping locally all new entries, and simply add them back when API is available…
Started writing something along the lines of (still need to fill in all the data fields and functions, need a "get user" function for example):
#!/usr/bin/env python3
import requests
from dataclasses import dataclass
import json
@dataclass
class Spliit():
group_id: str
def get_group(self):
params_input = {"0":{"json":{"groupId": self.group_id }},"1":{"json":{"groupId": self.group_id}}}
params = {
'batch': '1',
"input": json.dumps(params_input)
}
response = requests.get('https://spliit.app/api/trpc/groups.get,groups.getDetails', params=params)
return response.content.decode()
def add_expense(self, amount: int = 1300):
params = {
'batch': '1',
}
json_data = {
'0': {
'json': {
'groupId': self.group_id,
'expenseFormValues': {
'expenseDate': '2024-11-14T22:26:58.244Z',
'title': 'aaa2',
'category': 0,
'amount': amount,
'paidBy': '1pv6Y2kYY-7Y2ch1sSrUL',
'paidFor': [
{
'participant': '1pv6Y2kYY-7Y2ch1sSrUL',
'shares': 100,
},
{
'participant': 'HdA1uEaY_vwPQ3V_e_phQ',
'shares': 100,
},
{
'participant': 'rI3LmjoengeQHZWVCR8ax',
'shares': 100,
},
],
'splitMode': 'EVENLY',
'saveDefaultSplittingOptions': False,
'isReimbursement': False,
'documents': [],
'notes': '',
},
'participantId': 'None',
},
'meta': {
'values': {
'expenseFormValues.expenseDate': [
'Date',
],
},
},
},
}
response = requests.post('https://spliit.app/api/trpc/groups.expenses.create', params=params, json=json_data)
return response.condent.decode()
if __name__ == "__main__":
a = Spliit(group_id = "3w4pzrjzIyu3xipruh_XR")
print(a.get_group())
I would love to have an API that allows me to insert new spendings. That way I could automate pays I made with my iPhone using Apples Shortcuts. It would remove the need of copy pasting values from one screen to another.
Here is an initial API: https://github.com/guysoft/SpliitApi