#Web service v2.0

#Articles
#Get an article
>>> import requests, json
>>> r = requests.get("https://newspipe.org/api/v2.0/article/1",
...                  headers={'Content-type': 'application/json'},
...                  auth=("your-nickname", "your-password"))
>>> r.status_code
200  # OK
>>> rjson = r.json()
>>> rjson["title"]
"Why pathlib.Path doesn't inherit from str in Python"
>>> rjson["date"]
'2016-03-29T11:50:50'
>>> rjson["link"]
>>> r = requests.get("https://newspipe.org/api/v2.0/article/1",
...                  headers={'Content-type': 'application/json'},
...                  auth=("your-nickname", "your-password"),
...                  data=json.dumps({'id__in': [1, 2]}))
>>> r.json()
[{'id': 1, 'title': 'article1', [...]},
 {'id': 2, 'title': 'article2', [...]}]
#Search an article
$ curl -u your-nickname:your-password -H -H "Content-Type: application/json" -d '{"title__contains":"postmarketOS"}' -X GET https://www.newspipe.org/api/v2.0/articles
[{"user_id": 90, "retrieved_date": "2020-04-18T22:42:56.606361", "entry_id": "https://lobste.rs/s/dszvkz", "category_id": null, "id": 607195, "content": "<p><a href=\"https://lobste.rs/s/dszvkz/iphone_7_boots_postmarketos_becomes\">Comments</a></p>", "date": "2020-04-18T19:30:09", "title": "iPhone 7 boots postmarketOS, becomes the first Apple Linux smartphone", "tags": ["linux", "mobile", "ios"], "like": false, "feed_id": 873, "updated_date": "2020-04-18T22:42:56.615229", "link": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "readed": false}, {"user_id": 123, "retrieved_date": "2020-04-18T23:06:40.121349", "entry_id": "https://lobste.rs/s/dszvkz", "category_id": null, "id": 607629, "content": "<p><a href=\"https://lobste.rs/s/dszvkz/iphone_7_boots_postmarketos_becomes\">Comments</a></p>", "date": "2020-04-18T19:30:09", "title": "iPhone 7 boots postmarketOS, becomes the first Apple Linux smartphone", "tags": ["linux", "mobile", "ios"], "like": false, "feed_id": 2727, "updated_date": "2020-04-18T23:06:40.130279", "link": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "readed": false}, {"user_id": 1, "retrieved_date": "2017-08-20T11:30:27.372436", "entry_id": "https://linux.slashdot.org/story/17/08/19/2359258/postmarketos-pursues-a-linux-based-lts-os-for-android-phones?utm_source=rss1.0mainlinkanon&utm_medium=feed", "category_id": 5, "id": 186384, "content": "An anonymous reader quotes Liliputing:\nBuy an iPhone and you might get 4-5 years of official software updates. Android phones typically get 1-3 years of updates... if they get any updates at all. But there are ways to breathe new life into some older Android phones. If you can unlock the bootloader, you may be able to install a custom ROM like LineageOS and get unofficial software updates for a few more years. The folks behind postmarketOS want to go even further: they're developing a Linux-based alternative to Android with the goal of providing up to 10 years of support for old smartphones... \nRight now postmarketOS is a touch-friendly operating system based on Alpine Linux that runs on a handful of devices including the Samsung Galaxy Nexus, Google Nexus 4, 5, and 7 (2012), and several other Samsung, HTC, LG, Motorola, and Sony smartphones. There are also ports for some non-Android phones such as the Nokia N900 and work-in-progress builds for the BlackBerry Bolt Touch 9900 and Jolla Phone. Note that when I say the operating system runs on those devices, I basically mean it boots. Some phones only have network access via a USB cable, for instance. None of the devices can actually be used to make phone calls. But here's the cool thing: the developers are hoping to create a single kernel that works with all supported devices, which means that postmarketOS would work a lot like a desktop operating system, allowing you to install the same OS on any smartphone with the proper hardware. \nOne postmarketOS developer complains that Android's architecture \"is based on forking (one might as well say copy-pasting) the entire code-base for each and every device and Android version. And then working on that independent, basically instantly incompatible version. Especially adding device-specific drivers plays an important role... Here is the solution: Bend an existing Linux distribution to run on smartphones. Apply all necessary changes as small patches and upstream them, where it makes sense.\"<p><div class=\"share_submission\" style=\"position:relative;\">\n<a class=\"slashpop\" href=\"http://twitter.com/home?status=postmarketOS+Pursues+A+Linux-Based%2C+LTS+OS+For+Android+Phones%3A+http%3A%2F%2Fbit.ly%2F2vPr7oH\"><img src=\"https://a.fsdn.com/sd/twitter_icon_large.png\"></a>\n<a class=\"slashpop\" href=\"http://www.facebook.com/sharer.php?u=https%3A%2F%2Flinux.slashdot.org%2Fstory%2F17%2F08%2F19%2F2359258%2Fpostmarketos-pursues-a-linux-based-lts-os-for-android-phones%3Futm_source%3Dslashdot%26utm_medium%3Dfacebook\"><img src=\"https://a.fsdn.com/sd/facebook_icon_large.png\"></a>\n\n<a class=\"nobg\" href=\"http://plus.google.com/share?url=https://linux.slashdot.org/story/17/08/19/2359258/postmarketos-pursues-a-linux-based-lts-os-for-android-phones?utm_source=slashdot&amp;utm_medium=googleplus\" onclick=\"javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;\"><img src=\"http://www.gstatic.com/images/icons/gplus-16.png\" alt=\"Share on Google+\"/></a>                                                                                                                                                                              \n\n\n\n</div></p><p><a href=\"https://linux.slashdot.org/story/17/08/19/2359258/postmarketos-pursues-a-linux-based-lts-os-for-android-phones?utm_source=rss1.0moreanon&amp;utm_medium=feed\">Read more of this story</a> at Slashdot.</p><iframe src=\"https://slashdot.org/slashdot-it.pl?op=discuss&amp;id=11011617&amp;smallembed=1\" style=\"height: 300px; width: 100%; border: none;\"></iframe><img src=\"http://feeds.feedburner.com/~r/Slashdot/slashdot/~4/IK95gs3t9SE\" height=\"1\" width=\"1\" alt=\"\"/>", "date": "2017-08-20T13:19:00", "title": "postmarketOS Pursues A Linux-Based, LTS OS For Android Phones", "tags": ["android"], "like": false, "feed_id": 65, "updated_date": "2017-08-20T13:19:00", "link": "https://linux.slashdot.org/story/17/08/19/2359258/postmarketos-pursues-a-linux-based-lts-os-for-android-phones?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Slashdot%2Fslashdot+%28Slashdot%29", "readed": true}, {"user_id": 28, "retrieved_date": "2020-04-18T22:30:54.053048", "entry_id": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "category_id": null, "id": 606863, "content": "<a href=\"https://news.ycombinator.com/item?id=22911379\">Comments</a>", "date": "2020-04-18T21:47:44", "title": "iPhone 7 boots postmarketOS, becomes the first Apple Linux smartphone", "tags": [], "like": false, "feed_id": 365, "updated_date": "2020-04-18T22:30:54.066218", "link": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "readed": false}, {"user_id": 92, "retrieved_date": "2020-04-18T22:37:46.979836", "entry_id": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "category_id": null, "id": 607073, "content": "<a href=\"https://news.ycombinator.com/item?id=22911379\">Comments</a>", "date": "2020-04-18T21:47:44", "title": "iPhone 7 boots postmarketOS, becomes the first Apple Linux smartphone", "tags": [], "like": false, "feed_id": 1041, "updated_date": "2020-04-18T22:37:46.995190", "link": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "readed": false}, {"user_id": 90, "retrieved_date": "2020-04-18T22:42:24.221337", "entry_id": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "category_id": null, "id": 607173, "content": "<a href=\"https://news.ycombinator.com/item?id=22911379\">Comments</a>", "date": "2020-04-18T21:47:44", "title": "iPhone 7 boots postmarketOS, becomes the first Apple Linux smartphone", "tags": [], "like": false, "feed_id": 868, "updated_date": "2020-04-18T22:42:24.235109", "link": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "readed": false}, {"user_id": 334, "retrieved_date": "2020-04-19T02:00:41.086788", "entry_id": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "category_id": null, "id": 607745, "content": "<a href=\"https://news.ycombinator.com/item?id=22911379\">Comments</a>", "date": "2020-04-18T21:47:44", "title": "iPhone 7 boots postmarketOS", "tags": [], "like": false, "feed_id": 1657, "updated_date": "2020-04-19T02:00:41.111566", "link": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "readed": false}, {"user_id": 125, "retrieved_date": "2020-04-18T23:06:23.801410", "entry_id": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "category_id": null, "id": 607603, "content": "<a href=\"https://news.ycombinator.com/item?id=22911379\">Comments</a>", "date": "2020-04-18T21:47:44", "title": "iPhone 7 boots postmarketOS", "tags": [], "like": false, "feed_id": 1434, "updated_date": "2020-04-18T23:06:23.816453", "link": "https://tuxphones.com/iphone-7-now-boots-postmarketos-linux/", "readed": false}, {"user_id": 1, "retrieved_date": "2018-04-16T18:25:49.172231", "entry_id": "https://lwn.net/Articles/751951/rss", "category_id": null, "id": 206731, "content": "Alpine Linux-based postmarketOS is touch-optimized and pre-configured for\ninstallation on smartphones and other mobile devices.  The postmarketOS\nblog <a href=\"https://postmarketos.org/blog/2018/04/14/lowlevel/\">introduces\npostmarketOS-lowlevel</a> which is a community project aimed at creating\nfree bootloaders and cellular modem firmware, currently focused on MediaTek\nphones. \"<span>But before we get started, please keep in mind that these\nare moon shots. So while there is some little progress, it's mostly about\nletting fellow hackers know what we've tried and what we're up to, in the\nhopes of attracting more interested talent to our cause. After all, our\nphilosophy is to keep the community informed and engaged during the\ndevelopment phase!</span>\"", "date": "2018-04-16T20:10:16", "title": "postmarketOS Low-Level", "tags": [], "like": false, "feed_id": 49, "updated_date": "2018-04-16T18:25:49.842361", "link": "https://lwn.net/Articles/751951/rss", "readed": true}, {"user_id": 1, "retrieved_date": "2018-06-09T18:23:26.239776", "entry_id": "https://lwn.net/Articles/757032/rss", "category_id": null, "id": 213060, "content": "Here's <a href=\"https://postmarketos.org/blog/2018/06/09/one-year/\">a\ndetailed update from the postmarketOS project</a> on its first year.\nPostmarketOS is building an Android distribution aimed at keeping older\ndevices working in a supported mode; much of this work involves getting\nmainline kernels working on various handsets.\n\"<span>You might remember @bshah's photo of the Nexus 5 running mainline\nwith a flipped and distorted screen from December. @flto continued his\nwork: the display works without problems now. But it gets even better: the\ntouch screen is working, 3D acceleration is enabled with the open source\nfreedreno userspace driver, Wi-Fi works, and the best part is that\n@MartijnBraam was able to send SMS and initialize a call via command line\nas well as getting the connectivity signal from the modem through oFono\ndisplayed in Plasma Mobile (#1502). All of that without proprietary\nuserspace blobs!</span>\"", "date": "2018-06-09T15:29:03", "title": "One year of postmarketOS", "tags": [], "like": false, "feed_id": 49, "updated_date": "2018-06-09T18:23:26.898397", "link": "https://lwn.net/Articles/757032/rss", "readed": true}]
#Add an article
>>> import requests, json
>>> headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
>>> payload = {'link': 'http://blog.cedricbonhomme.org/2014/05/24/sortie-de-pyaggr3g470r-5-3/',
...            'title': 'Sortie de pyAggr3g470r 5.3',
...            'content':'La page principale de pyAggr3g470r a été améliorée...',
...            'date':'2014/06/23T11:42:20 GMT',
...            'feed_id':'42'}
>>> r = requests.post("https://newspipe.org/api/v2.0/article",
...                   headers=headers, auth=("your-nickname", "your-password"),
...                   data=json.dumps(payload))
>>> r.status_code
201  # Created
>>> # creating several articles at once
>>> r = requests.post("https://newspipe.org/api/v2.0/article",
...                   headers=headers, auth=("your-nickname", "your-password"),
...                   data=json.dumps([payload, payload]))
>>> r.status_code
201  # Created
>>> r.json()
[123456, 234567]
>>> r = requests.get("https://newspipe.org/api/v2.0/articles",
...                  auth=("your-nickname", "your-password")
...                  data=json.dumps({'feed_id': 42, 'limit': 1}))
>>> r.json()[0]["title"]
"Sortie de pyAggr3g470r 5.3"
#Update an article
>>> import requests, json
>>> r = requests.put("https://newspipe.org/api/v2.0/article/65",
...                  headers={'Content-Type': 'application/json'},
...                  auth=("your-nickname", "your-password"),
...                  data=json.dumps({"like":True, "readed": False}))
>>> r.status_code
200  # OK
>>> r = requests.put("https://newspipe.org/api/v2.0/articles",
...                  headers={'Content-Type': 'application/json'},
...                  auth=("your-nickname", "your-password"),
...                  data=json.dumps([[1, {"like": True, "readed": False}],
...                                   [2, {"like": True, "readed": True}]]))
>>> r.json()
['ok', 'ok']
#Delete one or several article(s)
>>> import json, requests
>>> r = requests.delete("https://newspipe.org/api/v2.0/article/84574",
...                     headers={'Content-Type': 'application/json'},
...                     auth=("your-nickname", "your-password"))
>>> r.status_code
204  # deleted - No content
>>> r = requests.delete("https://newspipe.org/api/v2.0/article/84574",
...                     headers={'Content-Type': 'application/json'},
...                     auth=("your-nickname", "your-password"))
>>> r.status_code
404  # not found
>>> r = requests.delete("https://newspipe.org/api/v2.0/articles",
...                     headers={'Content-Type': 'application/json'},
...                     auth=("your-nickname", "your-password")
...                     data=json.dumps([84574]))
>>> r.status_code
500 # already deleted
>>> r = requests.delete("https://newspipe.org/api/v2.0/articles",
...                     headers={'Content-Type': 'application/json'},
...                     auth=("your-nickname", "your-password")
...                     data=json.dumps([84575, 84576]))
>>> r.status_code
204  # deleted - No content
>>> r = requests.delete("https://newspipe.org/api/v2.0/articles",
...                     headers={'Content-Type': 'application/json'},
...                     auth=("your-nickname", "your-password")
...                     data=json.dumps([84575, 84576, 84577]))
>>> r.status_code
206  # partial - some deleted
>>> r.json()
['404 - Not Found', '404 - Not Found', 'ok']
#Feeds
#Add a feed
>>> import json, requests
>>> r = requests.post("https://newspipe.org/api/v2.0/feeds",
...                   auth=("your-nickname", "your-password"),
...                   headers={'Content-Type': 'application/json'},
...                   data=json.dumps({'link': 'http://blog.cedricbonhomme.org/feed'}))
>>> r.status_code
200
#Update a feed
>>> import json, requests
>>> r = requests.put("https://newspipe.org/api/v2.0/feeds/42",
...                  auth=("your-nickname", "your-password"),
...                  headers={'Content-Type': 'application/json'},
...                  data=json.dumps({"title":"Feed new title", "description":"New description"})
>>> r.status_code
201
#Delete a feed
>>> import requests
>>> r = requests.delete("https://newspipe.org/api/v2.0/feeds/29",
...                     auth=("your-nickname", "your-password"))

About this wiki

commit f583aa79702061173357072f370cdf025bc95421
Author: Cédric Bonhomme <cedric@cedricbonhomme.org>
Date:   2020-10-27T14:32:59+01:00

new: added an example on how to look for an article via the API.
Clone this wiki
https://git.sr.ht/~cedric/newspipe-docs (read-only)
git@git.sr.ht:~cedric/newspipe-docs (read/write)