Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request : creating note without app - but with api or something :) #305

Closed
foxmask opened this Issue Mar 16, 2018 · 18 comments

Comments

Projects
None yet
4 participants
@foxmask
Copy link
Collaborator

foxmask commented Mar 16, 2018

Hi,
I'm the author of a free alternative of IFTTT.com which allows to triggers the creation of data from one service to another.
For example grabbing RSS Feeds from our favorites websites and push the news to Evernote, Twitter, Mastodon Slack, Tagaio Mastermotte and so on.
My request is: is it possible to know how to create a note in joplin without using any client application but with an API or if no API, a Howto that could explain how to create a consistent note ?
It's may be very too early in the project for that but that will be very cool :)
regards

@laurent22

This comment has been minimized.

Copy link
Owner

laurent22 commented Mar 16, 2018

Since Joplin syncs with various cloud services, there's currently no uniform web API. To add a note you would need for example to use the OneDrive API and drop the markdown file in the synced folder. Joplin will then pick it up. The file format is relatively simple, though not currently documented, but I can do so if needed.

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 16, 2018

Ok. I'll made some tests this weekend.

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 17, 2018

On OneDrive I created a file from their web interface, and I tried to add a file in " Files > Applications > Joplin " and in "Files > Applications > Joplin > .sync "

but when syncing I don't find the file integrated in Joplin by searching "migrer" (for example)

In which folder do I have to add such a file to be picked up by joplin ?

@laurent22

This comment has been minimized.

Copy link
Owner

laurent22 commented Mar 17, 2018

The note indeed needs to be added to Files/Applications/Joplin with the other .md files but it needs to have a specific format to be picked by the app.

In order to create an item that can be synced you need to gather this information:

  • TITLE: eg. "My custom note"
  • BODY: eg. "The content of the note in markdown"
  • ITEM_ID: Globally unique ID. eg "00a4b16b6fa0436d9ab262f55c100f50"
  • NOTEBOOK_ID: The ID of the parent notebook. This is the tricky part as notebook IDs are not visible in the app. The easiest way is either to open the app profile in SQLiteStudio and get the ID from the "folders" table, or to search for "type_: 2" in the sync folder (type "2" is a notebook, while type "1" is a note). Basically you need to know the ID of the notebook where you want to add the note to.
  • DATE: The current date in UTC format. eg "2017-08-20T20:25:24.795Z.

Once you have the info above, you can build a note using the info above. The file must be named as ITEM_ID.md (eg. 00a4b16b6fa0436d9ab262f55c100f50.md) to be picked up by the app.

This would be the content:


My custom note

The content of the note in markdown
which can spread
multiple lines.

id: <ITEM_ID>
parent_id: <NOTEBOOK_ID>
created_time: <THE_DATE>
updated_time: <THE_DATE>
is_conflict: 0
latitude: 0.00000000
longitude: 0.00000000
altitude: 0.0000
author:
source_url:
is_todo: 0
todo_due: 0
todo_completed: 0
source:
source_application:
application_data:
order: 0
user_created_time: <THE_DATE>
user_updated_time: <THE_DATE>
encryption_cipher_text:
encryption_applied: 0
type_: 1

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 18, 2018

Great !
How is calculated the ITEM_ID ? it's a uuid ? a hash ?

@laurent22

This comment has been minimized.

Copy link
Owner

laurent22 commented Mar 19, 2018

It's a UUID but without the "-" characters, so 32 characters long.

In the app, it's generated using this module and this code:

const uuidv4 = require('uuid/v4');
uuidv4().replace(/-/g, '');

Although how it's generated is not too important, what matters is that this ID is unique and doesn't conflict with the ID of another note.

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 19, 2018

Hi,
The most complicated part is to map folder name with its uuid without having the database to check all of that.
In that statement we can't "just create a file on the Cloud" that will be eaten by joplin during the sync process.
If I have to check into the database, it's like rewritting joplin in python, it's not the goal :)
One idea would be to have a dump of the "folder" database table on "the cloud" (and another one with the uuid of note to avoid conflicts)
But I don't want you to make weight modification on joplin for that so I think we can close that issue because after all that researches, it's not possible, is it ?
Thank you for your explanation and patience
Regards

@laurent22

This comment has been minimized.

Copy link
Owner

laurent22 commented Mar 19, 2018

Yes there's currently no built-in solution to do this. If you have access to the SQLite database it's straightforward to get the notebook ID but otherwise it's indeed more complicated.

What application do you have in mind? Is it a web service that would post a note to the user's account, or something already running on the user's computer?

Perhaps there should be an alternative property like "parent_title" and, if present, the note would be moved to the notebook with this title. If the notebook doesn't exist it could be created.

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 19, 2018

As you wrote earlier, the main access point is the cloud provider, from where joplin sync anything. It's perfect.

So I thought I could create notes in joplin, automatically with a lib (I'd have written), from various sources of data like RSS Feeds for example. I already did that with Evernote and many others services.

It's true that using the database is simple, but I find it's not fair to use your work that way.

But most of all, the idea was to create a note on the cloud that could be accessible from anywhere, because of your project which offers that possibility.

@blissb2599

This comment has been minimized.

Copy link

blissb2599 commented Mar 20, 2018

I like this idea.

Full disclosure, I'm not a developer, I just manage a team of them (the proverbial "pointy haired boss") -- so if this is a silly thought, please ignore... :)

What if, rather than writing directly to Joplin, you were to write a markdown file to a "to-be-ingested" folder? Then, the next time Joplin is launched or runs a sync, it could check that location to see if there's anything there, import it properly, and then delete it from the "to-be-ingested" folder... This way, instead of trying to recreate an actual Joplin note, complete with IDs etc., you just need to write a properly formatted markdown file, and then read it in using the existing import functionality.

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 20, 2018

The idea is to do as less as possible but to get more :)
So no manual action.
This is why I imagined a way to automate the notes creation.
One solution could be to use the joplin command line mode, but that will mean we have the hand on a local joplin desktop version.
Then if so, no need to automate anything, just use the joplin desktop client and that's all.
no?

@laurent22

This comment has been minimized.

Copy link
Owner

laurent22 commented Mar 21, 2018

Yes for automation tools, the command line client can help, especially in Shell Mode as it means commands can be run from a Bash or Python script for instance.

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 26, 2018

I close that request because there is no way to create notes on a server, without having to install a joplin client.

@foxmask foxmask closed this Mar 26, 2018

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 26, 2018

A way to reach the expected behavior will be to create a joplin.json file on OneDrive containing an array with the folder name and hash
eg

{
  "folders": [
    {
      "key": "the_uuid",
      "name": "Home"
    },
    {
      "key": "other_uuid",
      "name": "Python"
    }
  ],
}

thus we could access to onedrive directly, get that file and add file in the right "hashed folder name"

@laurent22

This comment has been minimized.

Copy link
Owner

laurent22 commented Mar 26, 2018

Adding redundant metadata to the sync target is not an option as it'd be near impossible to keep it in sync (most targets don't support atomic operations).

Of the options proposed here, I think those two would work:

  • Use the CLI, along with Bash or something else for automation.
  • Another option would be have a folder on the sync target which can be used to post notes, which are then added to the clients during sync. That would require adding support for this on Joplin though.
@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Mar 26, 2018

This last idea would be great :)

@mat-m

This comment has been minimized.

Copy link

mat-m commented Aug 17, 2018

Well, if the target folder is created in Joplin, you can get the uuid by reading the .md directly on the sync target, and make it a setting of your app.
My 2 cents.

@foxmask

This comment has been minimized.

Copy link
Collaborator Author

foxmask commented Aug 18, 2018

@mat-m now I use the webclipper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.