MarvinAPI icon indicating copy to clipboard operation
MarvinAPI copied to clipboard

[REQUEST] Add method to log Habits via API

Open brendanshoe opened this issue 3 years ago • 1 comments

Statement of purpose I do solemnly swear (or affirm) that this is an API feature request and not a Marvin feature request. For a Marvin feature request I would use Product Board.

Is your feature request related to a problem? Please describe. I use a habit tracker on iOS as a convenient way to track my habits, but there doesn't seem to an easy way to integrate this with Marvin, as the iOS Marvin app doesn't have shortcuts/the concept of habits and there isn't an easy API endpoint that I could use to keep the two tools in sync with using API requests implemented as iOS Shortcuts.

Describe the solution you'd like An endpoint on the API where you could track a new execution of a habit given the habit's ID and no other state

Describe alternatives you've considered I've investigated using the CouchDB database's API, however in order to record my daily execution of a habit, I'd have to do a PUT of the existing record with a copy of all the existing information including history and also insert a new record in the history array. This proved to be difficult to implement using Shortcuts in iOS, as a lot was involved in keeping the existing state of the task in addition to adding the new history item.

Additional context Initial requests were made in https://github.com/amazingmarvin/MarvinAPI/issues/7, but the main resolution to that issue was the addition of webhooks which isn't quite the same as logging via an external app.

brendanshoe avatar Apr 08 '21 21:04 brendanshoe

@brendanshoe take a look at this repo, if you are familiar with deploying Ruby apps it can be set up in Heroku pretty easily and you get your own custom GET endpoints to track the execution of habits.

https://github.com/pantulis/amazing_marvin_habit_bumper

pantulis avatar Dec 23 '21 12:12 pantulis

Hi @brendanshoe, @pantulis: I have documented this API (https://github.com/amazingmarvin/MarvinAPI/wiki/Marvin-API#habits). Be sure to include updateDB=true so that the cloudant database also gets updated. Otherwise the Marvin UI won't be up-to-date until you record again. I haven't tested this yet, so let me know if you run into any issues!

mltucker avatar Mar 09 '23 16:03 mltucker

@mltucker Thanks for updating the docs. Just wanted to let you know that I was able to successfully use the docs for interacting with the Habits API, specifically recording and listing habits, so this was very helpful.

Unrelated to documenting the API, but did notice that /habits endpoint didn't list the name of the habits, only the IDs. I was able to work around this by interacting with the database to find a habit by name and find it's ID, but would be nice to have in the API. Likewise, when recording a habit it would be nice to make the timestamp of recording the habit optional and just use the current timestamp, but again using the API was still much easier than the previous process I had to update via the database. I can always submit those as requests as the future if they were huge annoyances, but just wanted to quickly pass that on. Thanks again.

brendanshoe avatar May 10 '23 19:05 brendanshoe