Skip to content

get transactions

Harmun edited this page May 17, 2019 · 2 revisions

get /transactions Admin Return all transactions as an array of objects None [ { id, debitAccountId, creditAccountId, amount, date }, ... ]

GET transactions

Returns all transactions in the database as an array of objects.
Currently no pagination exists for this feature.

See GET transactions/:id for returning a single transaction by its id.
Additionally see GET /transactions/?account=[account] to return accounts belonging to a specific owner.

Restrictions

  • Can only be used by the admin role

Resource Information

Response formats JSON
Requires authentication? Yes, admin only

Example Request

curl -X GET \
  http://localhost:3000/transactions \
  -H 'Authorization: Bearer 123testtoken123' \
  -H 'Host: localhost:3000' 

Parameters

account can be added as a parameter to get all accounts owner by a specific user's id. For specifics see GET /transaction/?account=[account]

Example Response

Transactions are returned as an array of objects like this:

[
    {
        "id": 1,
        "debitAccountId": 1,
        "creditAccountId": 2,
        "amount": 200,
        "date": "2019-05-16T14:55:01.000Z"
    },
    {
        "id": 2,
        "debitAccountId": 1,
        "creditAccountId": 3,
        "amount": 1000,
        "date": "2019-05-16T14:55:01.000Z"
    },
    {
        "id": 3,
        "debitAccountId": 1,
        "creditAccountId": 4,
        "amount": 300,
        "date": "2019-05-16T14:55:01.000Z"
    },
    {
        "id": 4,
        "debitAccountId": 1,
        "creditAccountId": 5,
        "amount": 900,
        "date": "2019-05-16T14:55:01.000Z"
    },
    {
        "id": 5,
        "debitAccountId": 1,
        "creditAccountId": 6,
        "amount": 700,
        "date": "2019-05-16T14:55:01.000Z"
    }
]