Xpenser API: Expenses

Query / List

URL: http://xpenser.com/api/v1.0/expenses/

Method: GET

Parameters:

Sample Usage:

List all expenses in the default report in xml format:

curl -u user:password "http://xpenser.com/api/v1.0/expenses/?format=xml"

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"

List all expenses in report 54 tagged with either "personal" or "cash":

curl -u user:password \
    "http://xpenser.com/api/v1.0/expenses/?report=54tags=personal&tags=cash"

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:

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:

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

Expense Data

curl -u "user:password" -d "VAT=34&GST=12" "http://localhost:8000/api/v1.0/expense/45/data"