Transaction

Each transaction has a state_id that must be stored locally. It allows fetching missing transactions (update, save, delete) from the API. When saving a new transaction, you must specify your own UUID in the id field of the JSON object. The API returns your UUID along with a system-generated ID (long). This facilitates asynchronous data updates and later modifications on the frontend.

Save transaction

PUT https://api.megoru.ru/api/transaction

Headers

Name
Value

Content-Type

application/json

Authorization

token

Body

Name
Type
Description

date

string

2024-12-02

amount

string

Transaction amount

transaction_type

string

INCOME | EXPENSE

description

string

Nullable

category

string

Transaction category

personal_id

number

Personal ID

id

string

The random UUID is sent so that we can later provide you with your UUID and long ID, allowing you to update it on your side.

Response

{
  "id": "f4f67f62-5a0e-4b16-b5cc-b4cc7f829bfe",
  "transaction": {
    "transaction_id": 1,
    "transaction_type": "INCOME",
    "category": "Salary",
    "amount": 1000,
    "date": "2024-12-02",
    "description": null,
    "state_id": 1,
    "deleted": false,
    "personal": {
      "id": 1,
      "name": "Личный счёт",
      "date": "2024-12-02",
      "blocked": false,
      "family": false
    }
  },
  "state_id": 1
}

Fetch new transactions

POST https://api.megoru.ru/api/transaction/state

Headers

Name
Value

Content-Type

application/json

Authorization

token

Body

Name
Type
Description

state_id

number

State

personal_id

number

Personal ID

Response

{
  "transactions": [
    {
      "transaction_id": 1,
      "transaction_type": "INCOME",
      "category": "Salary",
      "amount": 1000,
      "date": "2024-12-02",
      "description": null,
      "state_id": 1,
      "deleted": false,
      "personal": {
        "id": 1,
        "name": "Личный счёт",
        "date": "2024-12-02",
        "blocked": false,
        "family": false
      }
    },
    {
      "transaction_id": 2,
      "transaction_type": "INCOME",
      "category": "Salary",
      "amount": 1000,
      "date": "2024-12-02",
      "description": null,
      "state_id": 2,
      "deleted": false,
      "personal": {
        "id": 1,
        "name": "Личный счёт",
        "date": "2024-12-02",
        "blocked": false,
        "family": false
      }
    }
  ],
  "deleted_transactions": [
    {
      "transaction_id": 1,
      "transaction_type": "INCOME",
      "category": "Salary",
      "amount": 1000,
      "date": "2024-12-02",
      "description": null,
      "state_id": 1,
      "deleted": true,
      "personal": {
        "id": 1,
        "name": "Личный счёт",
        "date": "2024-12-02",
        "blocked": false,
        "family": false
      }
    }
  ],
  "state_id": 4
}

Get all transactions

GET https://api.megoru.ru/api/transaction

Headers

Name
Value

Content-Type

application/json

Authorization

token

Response

{
  "transactions": [
    {
      "transaction_id": 1,
      "transaction_type": "INCOME",
      "category": "Salary",
      "amount": 1000,
      "date": "2024-12-02",
      "description": null,
      "state_id": 1,
      "deleted": false,
      "personal": {
        "id": 1,
        "name": "Личный счёт",
        "date": "2024-12-02",
        "blocked": false,
        "family": false
      }
    },
    {
      "transaction_id": 2,
      "transaction_type": "INCOME",
      "category": "Salary",
      "amount": 1000,
      "date": "2024-12-02",
      "description": null,
      "state_id": 2,
      "deleted": false,
      "personal": {
        "id": 1,
        "name": "Личный счёт",
        "date": "2024-12-02",
        "blocked": false,
        "family": false
      }
    }
  ],
  "state_id": 2
}

Delete transaction

DELETE https://api.megoru.ru/api/transaction/{id}

Headers

Name
Value

Content-Type

application/json

Authorization

token

PathVariable

Name
Type
Description

id

number

Transaction ID

Response

{
  "id": 3,
  "state_id": 4
}

Update transaction

PATCH https://api.megoru.ru/api/transaction

Headers

Name
Value

Content-Type

application/json

Authorization

token

Body

Name
Type
Description

date

string

2024-12-02

amount

string

Transaction amount

category

string

Transaction category

id

string

Transaction ID

Response

{
  "id": 10,
  "state_id": "11"
}

Last updated