Skip to content

Repository files navigation

Stock API

Publish Workflow

PHP REST API to track stock portfolio.
http://stock-api.schademarmelade.de/

REST API Index Page

(Updated during Session #55 👨‍💻 April 2025)

Development

This repo is using PHP and Composer from https://github.com/ramdacxp/php-devenv, which needs to be cloned into a parallel folder php-devenv.

A Maria DB plus webserver hosting PHPMyAdmin can be started via:

database

In a development shell composer can be used to install required PHP packages and to start a development webserver, which then serves the project at locally at http://localhost:8080/:

devenv
composer install
composer start

Project Features

  • GitHub Publish Workflow
  • SQL sample files
  • PHP Micro Framework Slim with DI and App Factory
  • Configuration for Production & Development
  • REST API with class based route handlers
  • Static file handler (can be mixed with REST API)
  • Report exceptions as JSON

Links

  • ramdacxp/php-devenv - Repo which is providing PHP development tools like PHP, Composer, MariaDB

  • Slim - PHP Micro Framework

  • Awesome PSR-15 Middlewares

  • ING Diba stock data REST API, e.g. for Microsoft, will provide the following JSON data:

    {
      "id": 951692,
      "name": "Microsoft",
      "price": 332.5,
      "close": 321.3,
      "bid": 332.45,
      "bidDate": "2025-04-23T19:07:05+02:00",
      "ask": 332.65,
      "askDate": "2025-04-23T19:07:05+02:00",
      "changePercent": 3.48583877995643,
      "changeAbsolute": 11.2,
      "instrumentTypeDisplayName": "Aktie",
      "wkn": "870747",
      "isin": "US5949181045",
      "internalIsin": "US5949181045",
      "stockMarket": "Direkthandel",
      "priceChangeDate": "2025-04-23T19:05:25+02:00",
      "currency": "EUR",
      "currencySign": "EUR",
      "pushSymbol": "X000ADB0200951692"
    }

SQL

Min, Max and last value per day:

SELECT * FROM (
  SELECT 
    name, 
    isin,
    DATE(priceChange) AS `day`,
    MIN(price) OVER (PARTITION BY name, isin, day) AS `min`,
    MAX(price) OVER (PARTITION BY name, isin, day) AS `max`,
    FIRST_VALUE(price) OVER (PARTITION BY name, isin, day ORDER BY priceChange DESC) AS `last`,
    priceChange AS `lastChange`
  FROM stockdata
) as temp
-- WHERE isin = 'dummyisi'
GROUP BY name, isin, day;

About

PHP REST API to track stock portfolio.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages