Payback API is a service to track and optimize debts between a group of friends.
Currently the Payback API does not provide authenticated access. Authentication will be implemented using OAuth, with logins by username and password, Facebook, Google and other services.
To prevent tampering of the data, a digital signature is included as a header in every request. The header name is X-Checksum and it is calculated using HMAC-SHA1 of the JSON representation of an object including url, query parameters and request body.
Where applicable this API uses the JSON media-type to represent resources states and affordances.
Requests with a message-body are using plain JSON to set or update resource states.
The common HTTP Response Status Codes are used.
Users related resources of the Payback API
A single User object. The User resource is the central resource in the Payback API. It represents one user of the service.
The User resource has the following attributes:
This method is only available for the authenticated user.
string (required) Example: johnID of the User
200ToggleContent-Type: application/json
{
"id": "johndoe",
"email": "johndoe@example.com"
}
403ToggleContent-Type: application/json
{ "error": "No permission" }
or
{ "error": "Invalid checksum" }
404ToggleContent-Type: application/json
{ "error": "User 'johndoe' does not exist." }
This method is only available for the authenticated user. email is the only modifiable field.
string (required) Example: johnID of the User
Content-Type: application/json
{
"email": "newemail@example.com"
}
200ToggleContent-Type: application/json
{
"id": "johndoe",
"email": "johndoe@example.com"
}
403ToggleContent-Type: application/json
{ "error": "No permission" }
or
{ "error": "Cannot update field 'whatever'" }
or
{ "error": "Invalid checksum" }
or
{ "error": "Email 'john@example.com' already exists." }
404ToggleContent-Type: application/json
{ "error": "User 'johndoe' does not exist." }
This method is only available for the authenticated user.
string (required) Example: johnID of the User
A single Debt object. The Debt resource represents a debt that a User has on another User.
A positive value means that this User owes something to another User, a negative value means that this User is owed by another User.
The Debt resource has the following attributes:
This method is only available for the authenticated user.
string (optional) Example: EURCurrency
200ToggleContent-Type: application/json
{
"debtId": 1,
"creditor": "john",
"debtor": "janeroe",
"originalValue": 100,
"value": 0,
"currency": "EUR",
"created": "2014-04-14T11:29Z",
"modified": "2014-04-15T09:10Z"
}
403ToggleContent-Type: application/json
{ "error": "No permission" }
or
{ "error": "Invalid checksum" }
404ToggleContent-Type: application/json
{ "error": "Debt '2' for user 'johndoe' does not exist." }
This method is only available for the authenticated user. The only modifiable field is value.
string (required) Example: johnID of the User
number (required) Example: 1ID of the Debt of a User
Content-Type: application/json
{
"value": 0,
"currency": "EUR"
}
200ToggleContent-Type: application/json
{
"debtId": 1,
"creditor": "john",
"debtor": "janeroe",
"originalValue": 100,
"value": 0,
"currency": "EUR",
"created": "2014-04-14T11:29Z",
"modified": "2014-04-15T09:10Z"
}
403ToggleContent-Type: application/json
{ "error": "No permission" }
or
{ "error": "Cannot update field 'whatever'" }
or
{ "error": "Invalid checksum" }
404ToggleContent-Type: application/json
{ "error": "Debt '2' for user 'johndoe' does not exist." }
This method is only available for the authenticated user.
string (required) Example: johnID of the User
number (required) Example: 1ID of the Debt of a User
Collection of all Debts that another User owes this User.
The Debts Collection resource has the following attribute:
This method is only available for the authenticated user.
string (optional) Example: EURCurrency
200ToggleContent-Type: application/json
{
"total": 2,
"balance": -3.4,
"credit": 0,
"debit": 3.4,
"currency": "EUR",
"debts":
[
{
"debtId": 1,
"creditor": "john",
"debtor": "janeroe",
"originalValue": 100,
"value": 0,
"currency": "EUR",
"created": "2014-04-14T11:29Z",
"modified": "2014-04-15T09:10Z"
},
{
"debtId": 2,
"creditor": "smith",
"debtor": "john",
"user": "smith",
"originalValue": 5.4,
"value": 3.4,
"currency": "EUR",
"created": "2014-04-16T08:30Z",
"modified": "2014-04-17T10:30Z"
}
]
}
403ToggleContent-Type: application/json
{ "error": "No permission" }
or
{ "error": "Invalid checksum" }
This method is only available for the authenticated user.
string (required) Example: johnID of the User
Content-Type: application/json
{
"user": "johndoe",
"value": 100,
"currency": "EUR"
}
201ToggleContent-Type: application/json
{
"created": [
{
"debtId": 2,
"creditor": "smith",
"debtor": "john",
"user": "smith",
"originalValue": 5.4,
"value": 3.4,
"currency": "EUR",
"created": "2014-04-16T08:30Z",
"modified": "2014-04-17T10:30Z"
}
],
"updated": [
{
"debtId": 1,
"creditor": "john",
"debtor": "janeroe",
"originalValue": 100,
"value": 0,
"currency": "EUR",
"created": "2014-04-14T11:29Z",
"modified": "2014-04-15T09:10Z"
}
]
}
403ToggleContent-Type: application/json
{ "error": "No permission" }
or
{ "error": "Invalid checksum" }
404ToggleContent-Type: application/json
{ "error": "User 'johndoe' does not exist." }
or
{ "error": "Value '0.0001' is invalid." }
A single Friend object. The Friend resource represents a friend of a User.
The Friend resource has the following attributes:
This method is only available for the authenticated user.
string (required) Example: johnID of the User
string (required) Example: janeID of a Friend of a User
200ToggleContent-Type: application/json
{
"id": "johndoe"
}
403ToggleContent-Type: application/json
{ "error": "No permission" }
or
{ "error": "Invalid checksum" }
404ToggleContent-Type: application/json
{ "error": "User 'johndoe' does not exist or is not a friend." }
This method is only available for the authenticated user.
string (required) Example: johnID of the User
string (required) Example: janeID of a Friend of a User
Collection of all Users that are Friends of a User.
This is a one-way only friendship and it is used to provide quick access to Users that are commonly used in the transactions.
The Friends Collection resource has the following attributes:
This method is only available for the authenticated user.
string (required) Example: johnID of the User
This method is only available for the authenticated user.
string (required) Example: johnID of the User
Content-Type: application/json
{ "id": "johndoe" }
201ToggleContent-Type: application/json
{ "id": "johndoe" }
403ToggleContent-Type: application/json
{ "error": "User 'johndoe' already friended." }
or
{ "error": "No permission" }
or
{ "error": "Invalid checksum" }
404ToggleContent-Type: application/json
{ "error": "User 'johndoe' does not exist." }
This method is only available for the authenticated user.
string (required) Example: johnID of the User
204403ToggleContent-Type: application/json
{ "error": "No permission" }
or
{ "error": "Invalid checksum" }
Collection of all Users.
The User Collection resource has the following attributes:
string (optional) Example: joFuzzy search. Only users that have an id or email related to the search parameter are returned.
string (optional) Example: joFuzzy search. Only users that have an id or email related to the search parameter are returned.
Content-Type: application/json
{ "id": "john", "email": "john@example.com", "passwordHash": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd" }
201ToggleContent-Type: application/json
{ "id": "john", "email": "john@example.com" }
403ToggleContent-Type: application/json
{ "error": "User 'john' already exists." }
or
{ "error": "Email 'john@example.com' already exists." }
or
{ "error": "Invalid checksum" }
Collection of all exchange rates.
The Exchange Rates resource has the following attributes:
200ToggleContent-Type: application/json
{
"base": "EUR",
"rates": {
"AUD": 1.4684,
"BGN": 1.9558,
"BRL": 3.0485,
"CAD": 1.4976,
"CHF": 1.2211
}
}
Generated by aglio on 03 Jun 2014