Skip to content

adborbas/grodt

Repository files navigation

Grodt

Grodt is a Vapor based personal finance REST API. It uses the Alphavantage API to get quotes and currency exchange rates.

Run locally

Prerequsite:

Steps:

  1. Clone the repository.
  2. Add your Alphavantage API key to a file named .alphavantagekey in the root of the repository. This path is added to .gitignore.
  3. Start the database locally by running docker compose up -d.
  4. Open the cloned repository in Xcode.
  5. Build and run.
  6. Please check the REST API section for details for interacting with Grodt.

The REST API

Authentication

You need to authenticate to the REST API to access the endpoints using a bearer token.

Getting a bearer token

Request

POST /login

Header: Authorization: Basic <credentials>, where <credentials> is the Base64 encoding of ID and password joined by a single colon :.

Please check the .env.development file for the default credentials.

Response
{
    "value": "<TOKEN>"
}

Authenticating with the token

You need to add the Authorization: Bearer <token>, where <token> is the string value you need to obtain with the /login endpoint above.

Endpoints

All endpoints are accessiable via the /api base path.

Portfolios

List portfolios

To get a list of the portfolios.

Get a portfolio

Returns the contents of a portfolio.

  • Request: GET /portfolios/<PORTFOLIO-ID>
  • Response: A Portfolio object.
Create a portfolio
  • Request: POST /portfolios
  • Body:
{
    "name": "String",
    "currency": "String" // The currency code
}
Delete a portfolio
  • Request: DELETE /portfolios/<PORTFOLIO-ID>

Transactions

Get a transaction

To get the details of a transaciton.

  • Request: GET /transactions/<TRANSACTION-ID>
  • Response: A Transaction object.
Create a transaction
  • Request: POST /transactions
  • Body:
{
    "portfolio": "String", // The portfolio ID
    "platform": "String",
    "account": "String", // OPTIONAL
    "purchaseDate": "Date",
    "ticker": "String",
    "currency": "String",
    "fees": "Decimal",
    "numberOfShares": "Decimal",
    "pricePerShare": "Decimal"
}
Delete a transaction
  • Request: DELETE /transactions/<TRANSACTION-ID>

Models

Portfolio

{
    "name": "String",
    "id": "String",
    "currency": "Currency",
    "performance": "Performance",
    "transactions": ["Transaction"]
}

Transaction

{
    "id": "String",
    "platform": "String", 
    "account": "String?", // OPTIONAL
    "purchaseDate": "Date",
    "ticker": "String",
    "currency": "Currency",
    "fees": "Decimal",
    "numberOfShares": "Decimal",
    "pricePerShareAtPurchase": "Decimal"
}

PortfolioInfo

{
    "name": "String",
    "id": "String",
    "performance": "Performance",
    "currency": "Currency",
    "transactions": "[String]", // Array of transaction IDs
}

Performance

Currency agnostic values. Response always contains a corresponding Currency.

{
    "profit": "Decimal",
    "moneyOut": "Decimal",
    "moneyIn": "Decimal",
    "totalReturn": "Decimal"
}

Currency

{
   "code": "String",
   "symbol": "String"
}

About

Grodt is a Vapor based personal finance REST API.

Resources

License

Stars

Watchers

Forks