Xpenser API: Reports

Query / List

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

Method: GET

Parameters:

Response

Sample Usage:

List all expenses in the default report in json format:

curl -u user:password "http://xpenser.com/api/v1.0/reports/"

curl -u user:password "http://xpenser.com/api/v1.0/reports/?status=A"

Response:

[
    {
        "status": "P", 
        "total": 762.14, 
        "id": 24, 
        "keyword": null, 
        "name": "Uncategorized Expenses"
    }, 
    {
        "status": "A", 
        "total": 331.16, 
        "id": 29,
        "keyword": "clientx", 
        "name": "Client X Report for November"
    }, 
    {
        "status": "U", 
        "total": 1234.01, 
        "id": 36, 
        "keyword": "nyc", 
        "is_default": true,
        "name": "New York Trip, Conference X"
    }
]

Create

URL: /api/v1.0/report/

Method: POST

Parameters:

Sample Usage:

curl -u user:password -d "name=June+Expenses" "http://xpenser.com/api/v1.0/report/"

Response:

{
    "status": "U", 
    "total": 762.14, 
    "name": "June Expenses",
    "keyword": "april", 
    "id": 115
}

Read

URL: /api/v1.0/report/{report_id}

Method: GET

Sample Usage:

curl -u user:password "http://xpenser.com/api/v1.0/report/114"

Response:

{
    "status": "U", 
    "total": 762.14, 
    "name": "April Expenses", 
    "keyword": "april", 
    "id": 114
}

Update

URL: /api/v1.0/report/{report_id}

Method: POST

Parameters:

Sample Usage:

curl -u user:password -d "name=Modified+report+name&status=R&keyword=something" \
    "http://xpenser.com/api/v1.0/report/115"

Response:

{
    "status": "R",
    "name": "Modified report name",
    "total": 321.11, 
    "keyword": "something", 
    "id": 115
}

Delete

URL: /api/v1.0/report/{report_id}/?action=delete

Method: POST

Sample Usage:

curl -u user:password -d "" "http://xpenser.com/api/v1.0/report/82"

Response: HTTP 204 return code

Read or Set Default Report

Read

URL: /api/v1.0/reports/default

Method: GET

Sample Usage:

curl -u user:password "http://xpenser.com/api/v1.0/reports/default"

Response:

{
    "name": "April Expenses", 
    "id": 89
}

Update

URL: /api/v1.0/reports/default/{report_id}

Method: POST

Sample Usage:

curl -u user:password -d "" "http://xpenser.com/api/v1.0/reports/default/115"

Response:

{
    "name": "May Expenses", 
    "id": 115
}