# Joplin API - Python

**URL:** https://discourse.joplinapp.org/t/joplin-api-python/1359
**Category:** Apps
**Created:** [14 January 2019 07:00 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359 "2019-01-14T07:00:37Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [14 January 2019 07:00 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/1 "2019-01-14T07:00:37Z")

</div>

Here is the Python version for the support of [Joplin API](https://joplin.cozic.net/api/) available from [https://github.com/foxmask/joplin-api](https://github.com/foxmask/joplin-api)

example of the way to create notes, ping the server, get notes and tags

```auto
>>> 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

```

---

<div class="post-metadata">

### Author: ![merlinuwe](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/merlinuwe/32/37_2.png) [@merlinuwe](https://discourse.joplinapp.org/u/merlinuwe)
#### Post date: [14 January 2019 22:06 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/2 "2019-01-14T22:06:42Z")

</div>

It seems that I failed by installing the api:

At first, I installed Git from here: [https://git-scm.com/download/win](https://git-scm.com/download/win)

In the git bash I called this

```auto
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,

```auto
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?

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [15 January 2019 06:10 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/3 "2019-01-15T06:10:18Z")

</div>

It’s ok on Windows that way. I fixed that behaviour but didn’t push it

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [15 January 2019 13:14 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/4 "2019-01-15T13:14:54Z")

</div>

should be better, let me know if you meet other issue

---

<div class="post-metadata">

### Author: ![merlinuwe](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/merlinuwe/32/37_2.png) [@merlinuwe](https://discourse.joplinapp.org/u/merlinuwe)
#### Post date: [15 January 2019 17:48 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/5 "2019-01-15T17:48:16Z")

</div>

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
>>>
```

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [15 January 2019 19:07 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/6 "2019-01-15T19:07:49Z")

</div>

ok I fixed that 🙂  
thanks for reporting.  
do a `git pull` and let me know

---

<div class="post-metadata">

### Author: ![merlinuwe](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/merlinuwe/32/37_2.png) [@merlinuwe](https://discourse.joplinapp.org/u/merlinuwe)
#### Post date: [15 January 2019 21:05 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/7 "2019-01-15T21:05:38Z")

</div>

The output of `git pull` looks well…

```
$ git pull
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 14 (delta 7), reused 14 (delta 7), pack-reused 0
Unpacking objects: 100% (14/14), done.
From https://github.com/foxmask/joplin-api
   d879979..b29dcf5 master -> origin/master
Updating d879979..b29dcf5
Fast-forward
 README.md | 1 -
 joplin_api/core.py | 20 +++-----------------
 test.py | 1 -
 3 files changed, 3 insertions(+), 19 deletions(-)

```

… 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
```

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [15 January 2019 22:52 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/8 "2019-01-15T22:52:45Z")

</div>

After git pull you need to redo

```
pip install -e .
```

---

<div class="post-metadata">

### Author: ![merlinuwe](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/merlinuwe/32/37_2.png) [@merlinuwe](https://discourse.joplinapp.org/u/merlinuwe)
#### Post date: [16 January 2019 17:58 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/9 "2019-01-16T17:58:13Z")

</div>

I did `pip install -e .` and got this:

```auto
    Obtaining file:///C:/Users/Uwe%20Wennmann/joplin-api
    Requirement already satisfied: requests==2.20.0 in c:\users\uwe wennmann\appdata\local\programs\python\python37\lib\site-packages (from joplin-api==1.2.2) (2.20.0)
    Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\users\uwe wennmann\appdata\local\programs\python\python37\lib\site-packages (from requests==2.20.0->joplin-api==1.2.2) (1.24)
    Requirement already satisfied: idna<2.8,>=2.5 in c:\users\uwe wennmann\appdata\local\programs\python\python37\lib\site-packages (from requests==2.20.0->joplin-api==1.2.2) (2.7)
    Requirement already satisfied: certifi>=2017.4.17 in c:\users\uwe wennmann\appdata\local\programs\python\python37\lib\site-packages (from requests==2.20.0->joplin-api==1.2.2) (2018.10.15)
    Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\uwe wennmann\appdata\local\programs\python\python37\lib\site-packages (from requests==2.20.0->joplin-api==1.2.2) (3.0.4)
    Installing collected packages: joplin-api
      Found existing installation: joplin-api 1.2.2
        Uninstalling joplin-api-1.2.2:
          Successfully uninstalled joplin-api-1.2.2
      Running setup.py develop for joplin-api
    Successfully installed joplin-api

```

Then I started the script again, and got this:

```
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]>
Traceback (most recent call last):
  File "H:\Dropbox\400 - Scriptprogrammierung\Python3\Joplin\JoplinAPI_Uwe.py", line 13, in <module>
    joplin.create_note(note_title, note_body, folder['id'])
TypeError: 'Response' object is not subscriptable
>>> 

```

(MYTOKEN was my Token from Joplin)

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [16 January 2019 19:53 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/10 "2019-01-16T19:53:14Z")

</div>

If you could paste your code to check what’s wrong, could be helpful.

---

<div class="post-metadata">

### Author: ![merlinuwe](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/merlinuwe/32/37_2.png) [@merlinuwe](https://discourse.joplinapp.org/u/merlinuwe)
#### Post date: [17 January 2019 07:50 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/11 "2019-01-17T07:50:11Z")

</div>

The code was stolen from [GitHub - foxmask/joplin-api: Joplin API](https://github.com/foxmask/joplin-api)  
😉

```
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
```

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [17 January 2019 08:41 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/12 "2019-01-17T08:41:50Z")

</div>

```auto
joplin.version()

```

this does not work at all, this has been removed from the API.  
I made a mistake in the README 🙂 I fixed it.

```auto
>>> 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.

---

<div class="post-metadata">

### Author: ![merlinuwe](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/merlinuwe/32/37_2.png) [@merlinuwe](https://discourse.joplinapp.org/u/merlinuwe)
#### Post date: [17 January 2019 12:00 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/13 "2019-01-17T12:00:43Z")

</div>

Used script:

```
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>
```

---

<div class="post-metadata">

### Author: ![merlinuwe](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/merlinuwe/32/37_2.png) [@merlinuwe](https://discourse.joplinapp.org/u/merlinuwe)
#### Post date: [23 January 2019 08:42 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/14 "2019-01-23T08:42:45Z")

</div>

At the next weekend I can furthermore test your windows releases, if you want.

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [23 January 2019 09:19 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/15 "2019-01-23T09:19:58Z")

</div>

it's nice from you, but use it only if you need it. I don't specially need test 🙂

---

<div class="post-metadata">

### Author: ![kartoo](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kartoo/32/324_2.png) [@kartoo](https://discourse.joplinapp.org/u/kartoo)
#### Post date: [24 January 2019 16:17 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/16 "2019-01-24T16:17:27Z")

</div>

Can this perform exports and imports?

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [24 January 2019 19:43 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/17 "2019-01-24T19:43:00Z")

</div>

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/](https://joplin.cozic.net/api/) to check out

---

<div class="post-metadata">

### Author: ![kartoo](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/kartoo/32/324_2.png) [@kartoo](https://discourse.joplinapp.org/u/kartoo)
#### Post date: [25 January 2019 04:47 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/18 "2019-01-25T04:47:13Z")

</div>

I do not know js I know a bit of Python so I was hoping to automate some file conversion and savings, that is why.

---

<div class="post-metadata">

### Author: ![foxmask](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@foxmask](https://discourse.joplinapp.org/u/foxmask)
#### Post date: [25 January 2019 07:11 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/19 "2019-01-25T07:11:28Z")

</div>

there is no JS implementation of the API describes at [https://joplin.cozic.net/api/](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 😉

---

<div class="post-metadata">

### Author: ![sciurius](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/sciurius/32/132_2.png) [@sciurius](https://discourse.joplinapp.org/u/sciurius)
#### Post date: [31 January 2019 20:07 UTC](https://discourse.joplinapp.org/t/joplin-api-python/1359/20 "2019-01-31T20:07:58Z")

</div>

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.

[Next page](https://discourse.joplinapp.org/t/joplin-api-python/1359.md?page=2)
