# Transaction

Since Stark Bank is centralized, we have a private ledger to keep track of all transactions. It's important to understand that every financial operation in Stark Bank generates a transaction that is registered in our ledger.

We create one automatically whenever a financial operation takes place in your workspace, such as when you make a Transfer, pay a Boleto or receive money from a paid Boleto.

### The Transaction object

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `id` | STRING | Unique identifier for the transaction. |
| `amount` | INTEGER | Transaction amount in cents of reais. Negative values represent cash-out. |
| `balance` | INTEGER | Balance in cents of reais after the transaction was processed. |
| `created` | STRING | Creation datetime of the transaction. Example: "2020-04-23T23:00:00.000000+00:00". |
| `description` | STRING | Description of the transaction. |
| `externalId` | STRING | Unique external identifier for the transaction. |
| `fee` | INTEGER | Fee charged by the transaction in cents of reais. |
| `receiverId` | STRING | ID of the workspace that received the amount. |
| `senderId` | STRING | ID of the workspace that sent the amount. |
| `source` | STRING | Reference to the operation that generated this transaction. Example: transfer/1234567890 |
| `tags` | LIST OF STRINGS | Tags associated with the transaction. |

### List Transactions

`GET /v2/transaction`

Your bank statement is the list of all transactions registered in your private ledger.

We return it paged.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `after` | OPTIONAL | Filter entities created after this date. |
| `before` | OPTIONAL | Filter entities created before this date. |
| `cursor` | OPTIONAL | String used to get the next batch of results. Our SDKs handle this for you. |
| `externalIds` | OPTIONAL | Filter transactions that carry the specified external IDs. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |
| `ids` | OPTIONAL | List of strings to get specific entities by ids. |
| `limit` | OPTIONAL | Number of results per cursor. Max = 100. |
| `tags` | OPTIONAL | Filter entities that contain the specified tags. |

**Request**

```python
import starkbank

transactions = starkbank.transaction.query(
    after="2020-04-01",
    before="2020-04-30"
)

for transaction in transactions:
    print(transaction)
```

**Response**

```python
Transaction(
    amount=-10000,
    created=2020-04-24 17:44:49.066074,
    description=A Lannister always pays his debts,
    external_id=my_unique_id,
    fee=0,
    id=5185595898855424,
    receiver_id=5651751147405312,
    sender_id=5083989094170624,
    source=self,
    balance=1567891,
    tags=['lannister', 'debts']
)
```

### Get a Transaction

`GET /v2/transaction/:id`

Get a single transaction by its id.

**Parameters**

| Name | Required | Description |
| --- | --- | --- |
| `id` | REQUIRED | Id of the transaction entity. |
| `fields` | OPTIONAL | List of strings to filter response JSON keys. Not available in the SDKs. |

**Request**

```python
import starkbank

transaction = starkbank.transaction.get("5185595898855424")

print(transaction)
```

**Response**

```python
Transaction(
    amount=-10000,
    created=2020-04-24 17:44:49.066074,
    description=A Lannister always pays his debts,
    external_id=my_unique_id,
    fee=0,
    id=5185595898855424,
    receiver_id=5651751147405312,
    sender_id=5083989094170624,
    source=self,
    balance=1567891,
    tags=['lannister', 'debts']
)
```

## Available Languages

Code samples on this page are in Python. The same content is available with samples in:

- [Python](https://docs.starkbank.com/api/v2/transaction-python.md)
- [Node.js](https://docs.starkbank.com/api/v2/transaction-node.md)
- [PHP](https://docs.starkbank.com/api/v2/transaction-php.md)
- [Java](https://docs.starkbank.com/api/v2/transaction-java.md)
- [Ruby](https://docs.starkbank.com/api/v2/transaction-ruby.md)
- [Elixir](https://docs.starkbank.com/api/v2/transaction-elixir.md)
- [.NET](https://docs.starkbank.com/api/v2/transaction-dotnet.md)
- [Go](https://docs.starkbank.com/api/v2/transaction-go.md)
- [Clojure](https://docs.starkbank.com/api/v2/transaction-clojure.md)
- [cURL](https://docs.starkbank.com/api/v2/transaction-curl.md)
