example of the way to create notes, ping the server, get notes and tags
>>> from joplin_api import JoplinApi
>>> joplin = JoplinApi(token='the token provided by Joplin in the WebClipper menu:P'))
>>> joplin.ping() # to check if the service is up
>>> joplin.get_folders() # to get all the folders
>>> folder_title = 'Default'
>>> folder = joplin.create_folder(folder_title) # to create a folder
>>> # to create a new note
>>> note_title = 'My title'
>>> note_body = '# My Title ## My Subtitle my body'
>>> joplin.create_note(note_title, note_body, folder['id'])
>>> joplin.get_notes() # to get all the notes
>>> joplin.get_tags() # to get all the tags
git clone https://github.com/foxmask/joplin-api
cd joplin-api
python setup.py install
Everything seemed to run fine. But when I call the first line of your script,
from joplin_api import JoplinApi
this happens:
Traceback (most recent call last):
File "H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin\JoplinAPI_Uwe.py", line 1, in <module>
from joplin_api import JoplinApi
ModuleNotFoundError: No module named 'joplin_api
What are the steps to install the Joplin API in Windows 10 64bit so that I can run a python script?
Thank you, this issue is solved. But the next one is here:
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
=================== RESTART: H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin\JoplinAPI_Uwe.py ===================
Traceback (most recent call last):
File "H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin\JoplinAPI_Uwe.py", line 5, in <module>
joplin.ping() # to check if the service is up
File "C:\Users\Uwe Wennmann\AppData\Local\Programs\Python\Python37\lib\site-packages\joplin_api-1.2.2-py3.7.egg\joplin_api\core.py", line 451, in ping
res = self.query('get', 'ping', **{})
File "C:\Users\Uwe Wennmann\AppData\Local\Programs\Python\Python37\lib\site-packages\joplin_api-1.2.2-py3.7.egg\joplin_api\core.py", line 66, in query
raise ValueError(f'request expected: notes, folders, tags, '
ValueError: request expected: notes, folders, tags, resources, version or ping but not ping
>>>
… but not the output of python, when I run the script:
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
=================== RESTART: H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin\JoplinAPI_Uwe.py ===================
Traceback (most recent call last):
File "H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin\JoplinAPI_Uwe.py", line 5, in <module>
joplin.ping() # to check if the service is up
File "C:\Users\Uwe Wennmann\AppData\Local\Programs\Python\Python37\lib\site-packages\joplin_api-1.2.2-py3.7.egg\joplin_api\core.py", line 451, in ping
res = self.query('get', 'ping', **{})
File "C:\Users\Uwe Wennmann\AppData\Local\Programs\Python\Python37\lib\site-packages\joplin_api-1.2.2-py3.7.egg\joplin_api\core.py", line 66, in query
raise ValueError(f'request expected: notes, folders, tags, '
ValueError: request expected: notes, folders, tags, resources, version or ping but not ping
from joplin_api import JoplinApi
#https://discourse.joplin.cozic.net/t/joplin-api-python/1359
joplin = JoplinApi(token='MYTOKEN')
joplin.ping() # to check if the service is up
joplin.get_folders() # to get all the folders
folder_title = 'Default'
folder = joplin.create_folder(folder_title) # to create a folder
# to create a new note
note_title = 'My title'
note_body = '# My Title ## My Subtitle my body'
joplin.create_note(note_title, note_body, folder['id'])
joplin.get_notes() # to get all the notes
joplin.get_tags() # to get all the tags
joplin.version() # to get the version of joplin
this does not work at all, this has been removed from the API.
I made a mistake in the README I fixed it.
>>> folder = joplin.create_folder(folder_title) # to create a folder
>>> folder_id = folder.json()['id']
>>> # to create a new note
>>> note_title = 'My title'
>>> note_body = '# My Title ## My Subtitle my body'
>>> joplin.create_note(note_title, note_body, folder_id)
>>> joplin.get_notes() # to get all the notes
>>> joplin.get_tags() # to get all the tags
this will be better
If you want to test all the API, you can run python test.py also this will create a couple of folders, notes in that created folder, and tags. All of this that can be removed once tests is ran, by dropping the created folders and tags.
from joplin_api import JoplinApi
#https://discourse.joplin.cozic.net/t/joplin-api-python/1359
joplin = JoplinApi(token='MYTOKEN')
joplin.ping() # to check if the service is up
joplin.get_folders() # to get all the folders
folder_title = 'Default'
folder = joplin.create_folder(folder_title) # to create a folder
folder_id = folder.json()['id']
# to create a new note
note_title = 'My title'
note_body = '# My Title ## My Subtitle my body'
joplin.create_note(note_title, note_body, folder_id)
joplin.get_notes() # to get all the notes
joplin.get_tags() # to get all the tags
Output from python:
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
=================== RESTART: H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin\JoplinAPI_Uwe.py ===================
method get path http://127.0.0.1:41184/ping/ params {'token': 'MYTOKEN'} payload {} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method get path http://127.0.0.1:41184/folders/ params {'token': 'MYTOKEN'} payload {} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method post path http://127.0.0.1:41184/folders/ params {'token': 'MYTOKEN'} payload {'title': 'Default', 'parent_id': 0} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method post path http://127.0.0.1:41184/notes/ params {'token': 'MYTOKEN'} payload {'title': 'My title', 'body': '# My Title ## My Subtitle my body', 'parent_id': '241a8a1a54f74375bb5cdcb4ac7b5099', 'author': '', 'source_url': '', 'tags': '', 'is_todo': ''} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method get path http://127.0.0.1:41184/notes/ params {'token': 'MYTOKEN'} payload {} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method get path http://127.0.0.1:41184/tags/ params {'token': 'MYTOKEN'} payload {} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
>>>
Output from cmd:
H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin>python JoplinAPI_Uwe.py
method get path http://127.0.0.1:41184/ping/ params {'token': 'MYTOKEN'} payload {} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method get path http://127.0.0.1:41184/folders/ params {'token': 'MYTOKEN'} payload {} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method post path http://127.0.0.1:41184/folders/ params {'token': 'MYTOKEN'} payload {'title': 'Default', 'parent_id': 0} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method post path http://127.0.0.1:41184/notes/ params {'token': 'MYTOKEN'} payload {'title': 'My title', 'body': '# My Title ## My Subtitle my body', 'parent_id': '48e2428c973e420699c9a2036b7cc0af', 'author': '', 'source_url': '', 'tags': '', 'is_todo': ''} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method get path http://127.0.0.1:41184/notes/ params {'token': 'MYTOKEN'} payload {} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
method get path http://127.0.0.1:41184/tags/ params {'token': 'MYTOKEN'} payload {} headers {'Content-Type': 'application/json'}
Response of WebClipper <Response [200]>
H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin>
The API does not provide that, and you don’t need that as you have the direct access to your data under your elbow with it. Look at https://joplin.cozic.net/api/ to check out
there is no JS implementation of the API describes at https://joplin.cozic.net/api/ , I just made one for Python.
If you want to automate file conversion then note creation, you can do it with the terminal command line as I spotted a mistake in my implem
The Python API has methods update_folder and rename_folder.
Basically, rename is update of the title only so the latter method is superfluous.
Also, the rename method uses PUT to /folders, which is not documented in the Joplin API.