portfolio icon indicating copy to clipboard operation
portfolio copied to clipboard

[new] REST API for Portfolio Performance

Open buchen opened this issue 4 years ago • 12 comments

First experimental daft of a REST API for Portfolio Performance.

If you want to test it:

  • Build the branch
  • Open the preferences, enable the web server and, optionally, set a token (otherwise a new one is created upon next restart)
  • For now, only one endpoint is implement: http://localhost:5712/api/v0/transactions

To request data:

  • Set X-PP-TOKEN with the token from the preferences
  • Set X-PP-FILE with the full path of a file currently open in PP (for now, it only works against files which are actually open)
Bildschirmfoto 2021-02-14 um 22 05 32 Bildschirmfoto 2021-02-14 um 22 05 20 Bildschirmfoto 2021-02-14 um 22 05 08

buchen avatar Feb 14 '21 21:02 buchen

Wow, so are you going through with this? Full api for read/write?

This will be killer, I'm thinking run the server (app) in docker and the community can create a modern web UI.

chrisaut avatar Feb 16 '21 08:02 chrisaut

Fantastic. In my mind this is also a better way to get often requested features like embedded scripts: you can just run the script outside and call into pp's API.

To @chrisaut idea of dockerizing a headless version, I think one missing piece is to be able to set the token from the command line (or env var or similar), so that one never has to touch the Eclipse UI.

Now I only need to figure out how to compile this locally :grin:

polymeris avatar Feb 16 '21 12:02 polymeris

A REST API would be great! I think for implementation, a Kotlin multiplatform project containing all model classes and serializers/deserializers would be ideal. This would be a separate project and probably also repository.

  • You would define the model classes in concise Kotlin code.
  • The Kotlin code would also contain JSON (and optionally additional formats) serializers/deserializers.
  • Kotlin compiles it to libraries for JVM, JavaScript and native code.
  • Not sure how well this works already, but at least in the future, the Java Script code would come with TypeScript definitions auto-generated from the Kotlin code.
  • You would add a dependency to the JVM library in your core code and use the model classes and serializers/deserializers just like Java classes.

The main benefit is that REST API clients could be developed much easier: There would be no need to manually infer Kotlin/Java classes (+ JSON mapping) for a JVM client, Swift classes (+ JSON mapping) for an iOS client, or TypeScript definitions for a JavaScript client.

Kotlin multiplatform is in alpha stage and the documentation is lagging. However, given what JetBrains has achieved with Kotlin, I trust it will become very good. I have some limited experience with Kotlin multiplatform and Kotlin multiplatform / multi-format reflectionless serialization and might be able to offer some help. E.g., if you, @buchen, are willing to give it a try, I could set up a mini project for the given draft.

marco-eckstein avatar Mar 24 '21 02:03 marco-eckstein

JTransaction uses double for amount and Double for shares. This is probably not ideal because of potential rounding errors. They should use BigDecimal in the JVM and a string in JSON. The Rest API of the exchange Binance usually uses strings for fractional numbers.

marco-eckstein avatar Mar 24 '21 02:03 marco-eckstein

@buchen Are there plans to expose full functionality as APIs? Certainly would be nice to expose them as endpoints (add/edit/delete security/account etc). I'd love to be able to host this on a raspberry pi or something and access it from any computer at home and/or my phone. At the moment it's not easy to sync this stuff across devices. This combined with headless mode (#1411) and a DB (#2216) would be great.

fugkco avatar Jul 10 '21 19:07 fugkco

Are there any plans update to update this branch? I am currently exploring to build a web UI based on the portfolio data from portfolio performance. For my prototype I am currently parsing the depot.xml, but it would of course be easier if I could directly access a running instance of portfolio performance.

Is there anything I can do to help progress this feature?

oxisto avatar Oct 24 '21 15:10 oxisto

So I tried to rebase this to the current master @ https://github.com/oxisto/portfolio/tree/rest-api. PP seems to start but unfortunately the Webserver itself is not started. The UI itself is working. Could it be that there is the plugin.xml missing from the server folder? I am not really familiar with how Eclipse PDE works :(

oxisto avatar Oct 24 '21 19:10 oxisto

So I tried to rebase this to the current master @ https://github.com/oxisto/portfolio/tree/rest-api. PP seems to start but unfortunately the Webserver itself is not started. The UI itself is working. Could it be that there is the plugin.xml missing from the server folder? I am not really familiar with how Eclipse PDE works :(

Update: I managed to get it running and currently working on the accounts and portfolio API.

oxisto avatar Oct 24 '21 20:10 oxisto

Is the REST API something that is still being worked on? I would love to get started using the data in python and build a web dashboard.

dvett01 avatar Aug 12 '22 07:08 dvett01

Is this still going on? It would be a great feature! :rocket:

JesusMtnez avatar May 12 '23 04:05 JesusMtnez

it would be lovely

forReason avatar Jul 07 '23 14:07 forReason