aboutsummaryrefslogtreecommitdiff
path: root/documentation
diff options
context:
space:
mode:
Diffstat (limited to 'documentation')
-rw-r--r--documentation/deployment.rst3
-rw-r--r--documentation/web-services.rst72
2 files changed, 38 insertions, 37 deletions
diff --git a/documentation/deployment.rst b/documentation/deployment.rst
index d0639c45..d06d55fe 100644
--- a/documentation/deployment.rst
+++ b/documentation/deployment.rst
@@ -92,6 +92,7 @@ If you want to use PostgreSQL
.. code-block:: bash
$ sudo apt-get install postgresql postgresql-server-dev-9.3 postgresql-client
+ $ pip install psycopg2
$ echo "127.0.0.1:5432:aggregator:pgsqluser:pgsqlpwd" > ~/.pgpass
$ chmod 700 ~/.pgpass
$ sudo -u postgres createuser pgsqluser --no-superuser --createdb --no-createrole
@@ -131,7 +132,7 @@ Configuration
=============
Configuration (database url, email, proxy, user agent, etc.) is done via the file *conf/conf.cfg*.
-Check these configuration before executing *db_create.py*.
+Check these configuration before executing *db_create.py*.
If you want to use pyAggr3g470r with Tor/Privoxy, you just have to set the value of
*http_proxy* (most of the time: *http_proxy = 127.0.0.1:8118**). Else leave the value blank.
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