Xpenser API: Expenses
Query / List
URL: http://xpenser.com/api/v1.0/expenses/
Method: GET
Parameters:
format: response format (json, xml)report: id of report to list expenses from. If omitted the "default" report will be used. If set to "*" expenses across all reports will be returned.type: Type of expensenotes: Expense notesamount,amount_op:amount: Amount of expenseamount_op: the operation to perform. Use "lt" for less than, "gt" for greater than.
date,date_op:date: Date of expense, specified as "%Y-%m-%d %H:%M:%S" - eg. 2009-08-26+00:00:00 .date_op: the operation to perform. Use "lt" for less than, "gt" for greater than.
created,created_op:created: Date expense was first created, specified as "%Y-%m-%d %H:%M:%S" (for example, 2009-08-26+00:00:00)created_op: the operation to perform. Use "lt" for less than, "gt" for greater than.
modified,modified_opmodified: Date expense was last modified, specified as "%Y-%m-%d %H:%M:%S" - eg. 2009-08-26+00:00:00modified_op: the operation to perform. Use "lt" for less than, "gt" for greater than.
status: Set it toallto include deleted expenses in the results. Normally you would not set this, but when doing synchronization this can be useful to explicitly indicate which expenses have been deleted. Note that deleted expenses will have a status of -1 .
Sample Usage:
List all expenses in the default report in json format:
curl -u user:password "http://xpenser.com/api/v1.0/expenses/?format=json"
List all expenses in the default report:
curl -u user:password "http://xpenser.com/api/v1.0/expenses/?format=json"
List all expenses in a specific report (report 54):
curl -u user:password "http://xpenser.com/api/v1.0/ expenses/?report=54&format=json"
List all expenses in all reports:
curl -u user:password "http://xpenser.com/api/v1.0/expenses/?report=*&format=json"
List all expenses in all reports with date later than 2009-08-26+00:00:00 :
curl -u user:password \ "http://xpenser.com/api/v1.0/expenses/?report=*&date_op=gt&date=2009-08-26+00:00:00"
List all expenses in report 54 with type "lunch":
curl -u user:password "http://xpenser.com/api/v1.0/expenses/?report=54&type=lunch&format=json"
List all expenses in report 54 with type "lunch" and amount greater than 25:
curl -u user:password \ "http://xpenser.com/api/v1.0/expenses/?report=54&type=lunch&amount=25&amount_op=gt&format=json"
List all expenses in all reports modified after 2009-08-26+00:00:00:
curl -u user:password \ "http://xpenser.com/api/v1.0/expenses/?report=*&modified=2009-08-26+00:00:00&modified_op=gt&format=json"
List all expenses in all reports modified after 2009-08-26+00:00:00, included deleted expenses:
curl -u user:password \ "http://xpenser.com/api/v1.0/expenses/?report=*&modified=2009-08-26+00:00:00&modified_op=gt&status=all"
Response:
[ { "status": 1, "rawamount": "119.61", "notes": "SAN to JFK", "created": "2009-10-22 10:11:00", "modified": "2009-10-22 10:11:00", "amount": "119.61", "date": "2009-09-23 10:10:00", "type": "Airfare", "id": 3807, "tags": [], "report_id": 110 }, { "status": 1, "receipt": { "image": "14/373835ab-17f7-4a0a-9c89-a26bf91f5687.JPG", "id": 7 }, "rawamount": "20", "notes": "San Diego airport", "created": "2009-10-22 10:14:33", "modified": "2009-10-22 10:14:33", "amount": "20", "date": "2009-09-25 10:14:00", "type": "Parking", "id": 3811, "tags": [ { "name": "travel", "id": 71 } ], "report_id": 110 }, { "status": 1, "rawamount": "4", "notes": "", "created": "2009-10-22 10:26:34", "modified": "2009-10-22 10:26:34", "amount": "4", "date": "2009-09-25 10:26:00", "type": "Travel: Lunch", "id": 3816, "tags": [ { "name": "meals", "id": 71 }, { "name": "cash", "id": 72 } ], "report_id": 110 } ]
Create
URL: /api/v1.0/expense/
Method: POST
Parameters:
q: The entire expense as a string. For example, "lunch $34.50 with Jack #personal #cash"d: Date of expense, specified as "%Y-%m-%d %H:%M:%S" (for example, 2009-08-26+00:00:00)r: ID of report to store expense in
Sample Usage:
curl -u user:password -d "q=lunch+34.50+with+jack" "http://xpenser.com/api/v1.0/expense/" curl -u user:password -d "q=lunch+34.50+with+jack+#personal+#cash&r=76&d=2009-10-02+05:14" \ "http://xpenser.com/api/v1.0/expense/"
Response:
{ "status": 1, "receipt": { "image": "14/373835ab-17f7-4a0a-9c89-a26bf91f5687.JPG", "id": 7 }, "rawamount": "34.50", "notes": "with jack", "created": "2009-11-20 22:44:21", "modified": "2009-11-20 22:44:22", "amount": "34.50", "date": "2009-10-02 05:14:00", "type": "lunch", "id": 3831, "tags": [ { "name": "personal", "id": 29 }, { "name": "cash", "id": 72 } ], "report_id": 76 }
Read
URL: /api/v1.0/expense/{expense_id}
Method: GET
Sample Usage:
curl -u user:password "http://xpenser.com/api/v1.0/expense/3831"
Response:
{ "status": 1, "receipt": { "image": "14/373835ab-17f7-4a0a-9c89-a26bf91f5687.JPG", "id": 7 }, "rawamount": "34.50", "notes": "with jack", "created": "2009-11-20 22:44:21", "modified": "2009-11-20 22:44:22", "amount": "34.50", "date": "2009-10-02 05:14:00", "type": "lunch", "id": 3831, "tags": [ { "name": "personal", "id": 29 }, { "name": "cash", "id": 72 } ], "report_id": 76 }
Update
URL: /api/v1.0/expense/{expense_id}
Method: POST
Parameters:
type, ,amount,notes: Type, amount, and notes for expenserawamount: The "raw" amount of the expense - for example, the raw mileage for mileage tracking, or the number of minutes for time tracking. The "amount" field always represents the amount of the expense in the local currency.date: Date of expense, specified as "%Y-%m-%d %H:%M:%S" (for example, 2009-08-26+00:00:00)report: ID of report to store expense intags: list of tags associated with the expense, space separated (for example, "personal cash")
Sample Usage:
curl -u user:password -d "tags=personal+cash&amount=34.50" "http://xpenser.com/api/v1.0/expense/45"
Response:
{ "status": 1, "receipt": { "image": "14/373835ab-17f7-4a0a-9c89-a26bf91f5687.JPG", "id": 7 }, "rawamount": "34.50", "notes": "with jack", "created": "2009-11-20 22:44:21", "modified": "2009-11-20 22:44:22", "amount": "34.50", "date": "2009-10-02 05:14:00", "type": "lunch", "id": 45, "tags": [ { "name": "personal", "id": 29 }, { "name": "cash", "id": 72 } ], "report_id": 76 }
Delete
URL: /api/v1.0/expense/{expense_id}?action=delete
Method: POST or DELETE
Sample Usage:
curl -u user:password -d "" "http://xpenser.com/api/v1.0/expense/45?action=delete"
Response: HTTP 204 return code