> For the complete documentation index, see [llms.txt](https://discoin.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://discoin.gitbook.io/docs/developers/implementation.md).

# Implementation

This page describes key API methods used to initiate transactions within the new API (Since [the auto-generated documentation](https://discoin.zws.im/docs) has several errors). You're welcomed to test everything out yourself.

## Get Transactions

<mark style="color:blue;">`GET`</mark> `https://discoin.zws.im/transactions/:id`

Retrieves transactions. All retrieved transactions will **NOT** be automatically marked as "Processed". A PATCH request (described later) will do so.\
API docs are mostly correct for this and are more detailed.

#### Path Parameters

| Name | Type   | Description     |
| ---- | ------ | --------------- |
| id   | string | Transaction ID. |

#### Query Parameters

| Name   | Type   | Description                                                                                                                                                                                                                                                   |
| ------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filter | string | Filter results of your query. If you don't specify this, the API returns *all* transactions. If you only want relevant unprocessed transactions, you can put`filter=to.id\|\|eq\|\|ABC&filter=handled\|\|eq\|\|false` here (gotta be URL encoded, of course). |

{% tabs %}
{% tab title="200 An array of transactions, or an object of transaction if :id is specified." %}

```javascript
[
  {
    "id": "188986c9-7f50-479b-a447-74ccbb9ab383",
    "amount": 10,
    "user": "210024244766179329",
    "handled": true,
    "timestamp": "2019-12-25T07:21:54.941Z",
    "payout": 1,
    "from": {
      "id": "OAT",
      "name": "Dice Oats"
    },
    "to": {
      "id": "DTS",
      "name": "Discordtel Credits"
    }
  }
]
```

{% endtab %}
{% endtabs %}

## Create New Transaction

<mark style="color:green;">`POST`</mark> `https://discoin.zws.im/transactions`

Request a transaction.

#### Headers

| Name          | Type   | Description             |
| ------------- | ------ | ----------------------- |
| Authorization | string | "Bearer " + your token. |

#### Request Body

| Name   | Type   | Description                                                                                                        |
| ------ | ------ | ------------------------------------------------------------------------------------------------------------------ |
| amount | number | Transaction amount in original currency.                                                                           |
| toId   | string | String, 3-letter currency code representing the destination currency. It's `"toId"` not the past form of `"told"`. |
| user   | string | ID of user who requested the transaction.                                                                          |

{% tabs %}
{% tab title="201 Shows transaction details. Notice that it provides the transaction ID as well." %}

```javascript
{
    "id": "b9cd2775-f354-4b6c-9a8b-5ad24b8cc11d",
    "amount": 1000,
    "user": "210024244766179329",
    "handled": false,
    "timestamp": "2019-12-25T18:27:27.773Z",
    "payout": 100.1,
    "from": {
        "id": "DTS",
        "name": "Discordtel Credits"
    },
    "to": {
        "id": "OAT",
        "name": "Dice Oats"
    }
}
```

{% endtab %}
{% endtabs %}

## Process transactions

<mark style="color:purple;">`PATCH`</mark> `https://discoin.zws.im/transactions/:id`

Update a transaction, usually this means marking a transaction as processed.

#### Path Parameters

| Name | Type   | Description     |
| ---- | ------ | --------------- |
| id   | string | Transaction ID. |

#### Headers

| Name          | Type   | Description             |
| ------------- | ------ | ----------------------- |
| Authorization | string | "Bearer " + your token. |

#### Request Body

| Name    | Type    | Description                                             |
| ------- | ------- | ------------------------------------------------------- |
| handled | boolean | Should be `true` to mark this transaction as processed. |

{% tabs %}
{% tab title="200 Shows updated transaction details." %}

```
{
    "id": "b9cd2775-f354-4b6c-9a8b-5ad24b8cc11d",
    "amount": 1000,
    "user": "210024244766179329",
    "handled": true,
    "timestamp": "2019-12-25T18:27:27.773Z",
    "payout": 100.1,
    "from": {
        "id": "DTS",
        "name": "DTel Credits"
    },
    "to": {
        "id": "OAT",
        "name": "Dice Oats"
    }
}
```

{% endtab %}
{% endtabs %}
