aboutsummaryrefslogtreecommitdiff
path: root/documentation/web-services.rst
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-03-01 14:08:02 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-03-03 22:23:47 +0100
commita4fb151ea53d8054cc8e3fb309395c8fa0e23aaf (patch)
tree6ce8c39978c83d22d2508da67f00c90232819855 /documentation/web-services.rst
parentnew crawler with cache control and error handling (diff)
downloadnewspipe-a4fb151ea53d8054cc8e3fb309395c8fa0e23aaf.tar.gz
newspipe-a4fb151ea53d8054cc8e3fb309395c8fa0e23aaf.tar.bz2
newspipe-a4fb151ea53d8054cc8e3fb309395c8fa0e23aaf.zip
fixing/restoring logging level
Diffstat (limited to 'documentation/web-services.rst')
-rw-r--r--documentation/web-services.rst72
1 files changed, 36 insertions, 36 deletions
diff --git a/documentation/web-services.rst b/documentation/web-services.rst
index 2d724569..dd2d0125 100644
--- a/documentation/web-services.rst
+++ b/documentation/web-services.rst
@@ -7,10 +7,11 @@ Articles
.. code-block:: python
>>> import requests, json
- >>> r = requests.get("https://pyaggr3g470r.herokuapp.com/api/v1.0/articles", auth=("your-email", "your-password"))
- >>> r.status_code-block
- 200
- >>> rjson = json.loads(r.text)
+ >>> r = requests.get("https://pyaggr3g470r.herokuapp.com/api/v2.0/articles",
+ ... auth=("your-nickname", "your-password"))
+ >>> r.status_code
+ 200 # OK
+ >>> rjson = r.json()
>>> rjson["result"][0]["title"]
u'Sponsors required for KDE code sprint in Randa'
>>> rjson["result"][0]["date"]
@@ -20,15 +21,19 @@ Possible parameters:
.. code-block:: bash
- $ curl --user your-email:your-password "https://pyaggr3g470r.herokuapp.com/api/v1.0/articles?filter_=unread&feed=24"
- $ curl --user your-email:your-password "https://pyaggr3g470r.herokuapp.com/api/v1.0/articles?filter_=read&feed=24&limit=20"
- $ curl --user your-email:your-password "https://pyaggr3g470r.herokuapp.com/api/v1.0/articles?filter_=all&feed=24&limit=20"
+ $ curl --user your-nickname:your-password "https://pyaggr3g470r.herokuapp.com/api/v2.0/articles" -H 'Content-Type: application/json' --data='{"feed": 24}'
-Get an article:
+Get an article with another way to pass credentials :
.. code-block:: bash
- $ curl --user your-email:your-password "https://pyaggr3g470r.herokuapp.com/api/v1.0/articles/84566"
+ $ curl "https://your-nickname:your-password@pyaggr3g470r.herokuapp.com/api/v2.0/article/84566"
+
+And delete it :
+
+.. code-block:: bash
+
+ $ curl -XDELETE "https://your-nickname:your-password@pyaggr3g470r.herokuapp.com/api/v2.0/article/84566"
Add an article:
@@ -36,13 +41,18 @@ 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':'06/23/2014 11:42 AM', 'feed_id':'42'}
- >>> r = requests.post("https://pyaggr3g470r.herokuapp.com/api/v1.0/articles", headers=headers, auth=("your-email", "your-password"), data=json.dumps(payload))
- >>> print r.content
- {
- "message": "ok"
- }
- >>> r = requests.get("https://pyaggr3g470r.herokuapp.com/api/v1.0/articles?feed=42&limit=1", auth=("your-email", "your-password"))
+ >>> 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://pyaggr3g470r.herokuapp.com/api/v2.0/article",
+ ... headers=headers, auth=("your-nickname", "your-password"), data=json.dumps(payload))
+ >>> print r.status_code
+ 201 # Created
+ >>> r = requests.get("https://pyaggr3g470r.herokuapp.com/api/v2.0/articles",
+ ... auth=("your-nickname", "your-password")
+ ... data=json.dumps({'feed_id': 42, 'limit': 1}))
>>> print json.loads(r.content)["result"][0]["title"]
Sortie de pyAggr3g470r 5.3
@@ -51,30 +61,20 @@ Update an article:
.. code-block:: python
>>> payload = {"like":True, "readed":False}
- >>> r = requests.put("https://pyaggr3g470r.herokuapp.com/api/v1.0/articles/65", headers=headers, auth=("your-email", "your-password"), data=json.dumps(payload))
- >>> print r.content
- {
- "message": "ok"
- }
+ >>> r = requests.put("https://pyaggr3g470r.herokuapp.com/api/v2.0/article/65", headers=headers, auth=("your-nickname", "your-password"), data=json.dumps(payload))
+ >>> print r.status_code
+ 200 # OK
Delete an article:
.. code-block:: python
- >>> r = requests.delete("https://pyaggr3g470r.herokuapp.com/api/v1.0/articles/84574", auth=("your-email", "your-password"))
+ >>> r = requests.delete("https://pyaggr3g470r.herokuapp.com/api/v2.0/article/84574", auth=("your-nickname", "your-password"))
>>> print r.status_code
- 200
- >>> print r.content
- {
- "message": "ok"
- }
- >>> r = requests.delete("https://pyaggr3g470r.herokuapp.com/api/v1.0/articles/84574", auth=("your-email", "your-password"))
+ 204 # deleted - No content
+ >>> r = requests.delete("https://pyaggr3g470r.herokuapp.com/api/v2.0/article/84574", auth=("your-nickname", "your-password"))
>>> print r.status_code
- 200
- >>> print r.content
- {
- "message": "Article not found."
- }
+ 404 # not found
Feeds
-----
@@ -84,17 +84,17 @@ Add a feed:
.. code-block:: python
>>> payload = {'link': 'http://blog.cedricbonhomme.org/feed'}
- >>> r = requests.post("https://pyaggr3g470r.herokuapp.com/api/v1.0/feeds", headers=headers, auth=("your-email", "your-password"), data=json.dumps(payload))
+ >>> r = requests.post("https://pyaggr3g470r.herokuapp.com/api/v2.0/feeds", headers=headers, auth=("your-nickname", "your-password"), data=json.dumps(payload))
Update a feed:
.. code-block:: python
>>> payload = {"title":"Feed new title", "description":"New description"}
- >>> r = requests.put("https://pyaggr3g470r.herokuapp.com/api/v1.0/feeds/42", headers=headers, auth=("your-email", "your-password"), data=json.dumps(payload))
+ >>> r = requests.put("https://pyaggr3g470r.herokuapp.com/api/v2.0/feeds/42", headers=headers, auth=("your-nickname", "your-password"), data=json.dumps(payload))
Delete a feed:
.. code-block:: python
- >>> r = requests.delete("https://pyaggr3g470r.herokuapp.com/api/v1.0/feeds/29", auth=("your-email", "your-password"))
+ >>> r = requests.delete("https://pyaggr3g470r.herokuapp.com/api/v2.0/feeds/29", auth=("your-nickname", "your-password"))
bgstack15