Settle Up offers API open to all developers. It's a REST-like simple API which gives you access to all data for online groups (if you have user's permission). With the API, you can create for example:
http://api.settleup.info - live stable APIhttp://sandbox.settleup.info - development
API, use when developing application! Can be unstable, datastore
can be cleared anytimehttp://<environment>.settleup.info/<resource>/<subresource>.<format>POST for creating or updating dataGET for retrieving dataUser-Agent:
<app_name>/<app_version> (<platform>;
<platform_version>; <user_language>)X-Api-Key: <your_API_key>Cookie: ACSID=<google_cookie>200 OK (with response data typically in JSON)204 No Content (no matching content found)400 Bad Request (wrong format of data from
client)401 Unauthorized (not invited to this group or
cookie expired)403 Forbidden (API key not valid)404 Not Found (calling unknown URL)426 Upgrade Required (newer version of client
needed to properly working)500 Internal Server Error (error on server)Settle Up doesn't have own user accounts. For ease of use, it uses Google or Facebook login. You can implement Google or Facebook or both. In addition you should implement "any e-mail verification". That ensures that group shared from Facebook e-mail will be usable on Google e-mail etc.
https://www.settleup.info/_ah/OAuthGetRequestTokenhttps://www.settleup.info/_ah/OAuthAuthorizeTokenhttps://www.settleup.info/_ah/OAuthGetAccessTokensandbox.settleup.info / api.settleup.info
(ask for consumer secret via mail)
http://sandbox.settleup.info/groups/oauth_user_infoah")
http://<environment>.settleup.info/_ah/login?auth=<auth_token>HTTP 302 and header Set-Cookie:
ACSID=<google_cookie> (don’t forget to disable automatic
redirects)
Update-Client-Auth:true - you
need to invalidate current authToken and login again
email, offline_accessaccess_token on device and send it with
every request using this header: Authorization:
fb_token=<access_token>access_token is invalid or expired, you will
receive HTTP 401 and reason in the body
"<new_email>"
to http://<environment>.settleup.info/emails/create.jsonGET
http://<environment>.settleup.info/emails/list.json. Response
is self-explanatory JSON with e-mails and whether they are verified.
"<del_email>"
to http://<environment>.settleup.info/emails/delete.jsonClient is expected to work offline, so it needs to have some sort of SQL-like database. For identifying records, you need to use online IDs. Online IDs can be computed on client as hash. Therefore server does not need to generate them. Online ID of any item is generated as:
onlineID =
firstTwentyChars(SHA1(<installationId>+<localId>))
installationId is identifying app installation.
It's calculated as hash(deviceId+big_random_number) and saved first
start of the applocalId is some id of item in local database,
can be SQL autoincrement primary key, but can be anything what
guarantees unique value for all data of one kind (payments, members,
…)Creation of online group is done by simple HTTP request. You specify basic information about the group, creator of the group and e-mails of others in the group. See Android version for recommended UI flow.
Request:POST
http://<environment>.settleup.info/groups/create.json
{
"creator":{"name":"<creator_name>", "email":"<creator_email>"},
"name": "<name_of_the_group>",
"language", "<language>",
"currency": {"code":"<currency_code>", "sign":"<currency_sign>"},
"id" : "<online_id>",
"permissions": [
{"name":"<member1_name>", "email":"<member1_email>"},
{"name":"<member2_name>", "email":"<member2_email>"},
...
]
}
Response:200 OK
*_name should be automatically fetched from
contacts for given e-mail. If name is unknown, e-mail should be
used.name_of_the_group - if empty, it should be made
of member names e.g. "Bob T., Jane M."language - ISO 639-1 language code like "en"currency_code - ISO 4217 currency code like
"USD"currency_sign - common sign for currency like
"$"This way you can get list of groups shared with current user (and his slave e-mails). You have all information required to create group, so no need for another request. After user joins the group, you should immediately start first synchronization.
Request:GET
http://<environment>.settleup.info/groups/list.json
200 OK
[
{"id":"<group_online_id>", "name":"<group_name>",
"currency": {"code":"<currency_code>", "sign":"<currency_sign>"}},
{"id":"<group_2_online_id>", "name":"<group_2_name>",
"currency": {"code":"<currency_code>", "sign":"<currency_sign>"}},
...
]
or204 No Content
(no matching group found) Synchronization is again just one HTTP request. It's meant to be done periodically, for example every hour. Only current group is synchronized. Sync works with changes, they are very general and can be used for any data table. However current Android version works with tables "payments", "members" and "groups". Specification of data inside these tables are in Tips for developing Settle Up for other platform.
In every sync, this is sent to server:POST
http://<environment>.settleup.info/groups/<group_online_id>/changes.json
{
"last_sync":<last_sync_timestamp>,
"data_version":1,
"inserts":[
{
"data_table":"<data_table>",
"id":"<record_online_id>",
"client_time":<client_timestamp>,
"data":"<data_values>"
},
...
],
"updates":[
...
],
"deletes":[
...
]
}
Response:200 OK
{
"last_sync":<last_sync_timestamp>,
"inserts":[
{
"data_table":"<data_table>",
"id":"<record_online_id>",
"author":"<author_email>",
"data":"<data_values>"
},
...
],
"updates":[
...
],
"deletes":[
...
]
}
Notes:
last_sync_timestamp is in server time. In first
sync it's null (downloads all changes), next time it's
value saved from last sync.data_table - currently "payments", "members" or
"groups"client_timestamp - UNIX time in millis - number
of milliseconds since 1.1.1970data_values - key-value data encoded as JSON
object. Must be escaped to string. See data structures for tables in
Tips for developing Settle Up for
other platform.
{"name":"..","email":"..","language":".."}http://<environment>.settleup.info/groups/<group_online_id>/permissions/create.json"<email_to_remove>"http://<environment>.settleup.info/groups/<group_online_id>/permissions/delete.jsonhttp://<environment>.settleup.info/groups/<group_online_id>/delete.jsonAre you developing iPhone, BlackBerry or Windows Phone app compatible with Settle Up? Read this page, it will be useful. Settle Up is designed to work offline, so there is quite a lot of work for client developer. I will try to speed it up and help you.
Intent intent = new Intent("cz.destil.settleup.NEW_PAYMENT");
intent.putExtra("amount", 5.5);
intent.putExtra("currency", "CZK"); // 3-chars ISO code
intent.putExtra("purpose", "Test");
intent.putExtra("datetime", System.currentTimeMillis() - 2 * 3600 * 1000); // two days ago
intent.putExtra("transfer", true); // transfer means that payment doesn't count into Total paid
try {
startActivityForResult(intent, 0);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("https://play.google.com/store/apps/details?id=cz.destil.settleup")));
}