{"id":55,"date":"2018-12-25T19:22:36","date_gmt":"2018-12-25T19:22:36","guid":{"rendered":"http:\/\/api.intelligentonlinetools.com\/diy\/?p=55"},"modified":"2018-12-27T02:44:47","modified_gmt":"2018-12-27T02:44:47","slug":"python-api-example-wallabag-web-application","status":"publish","type":"post","link":"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/","title":{"rendered":"Python API Example with Wallabag Web Application"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/12\/python-and-wallabag.png\" alt=\"python and wallabag\" width=\"404\" height=\"215\" class=\"aligncenter size-full wp-image-62\" srcset=\"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/12\/python-and-wallabag.png 404w, http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/12\/python-and-wallabag-300x160.png 300w\" sizes=\"(max-width: 404px) 100vw, 404px\" \/><\/p>\n<h2>Wallabag<\/h2>\n<p>Many a times it happens that we need to create <b>API<\/b> to post data to some web application using python framework.<br \/>\nTo over come this problem of sending data to application from outside of it, using API,  I am going to show how you can do this for Wallabag Web Application. <b>Wallabag<\/b> is Read It Later type of application, where you can save website links, and then read later.  <\/p>\n<p>Thus we will look here how to write API script that can send information to Wallabag web based application.<\/p>\n<p>To do this we need access to Wallabag. It is open open source project (MIT license) so you can download and install as self hosted service. <\/p>\n<h2>Collecting Information<\/h2>\n<p>Once we installed Wallabag or got access to it, we will collect information needed for authorization.<br \/>\nGo to Wallabag application, then API Client Management Tab and create the client.<br \/>\nNote client id, client secret.<br \/>\nSee below screenshot for references.<br \/>\n<img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/12\/wallabag_api_clients.png\" alt=\"\" width=\"518\" height=\"449\" class=\"aligncenter size-large wp-image-63\" srcset=\"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/12\/wallabag_api_clients.png 518w, http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/12\/wallabag_api_clients-300x260.png 300w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/p>\n<h2>Python API Example Script<\/h2>\n<p>Now we can go to python IDE and write the script as below. Here https:\/\/mysite.com is base url, wallabag is an installation folder where we installed application.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n\r\nimport requests\r\n\r\n\r\n# below 5 variables have to be set\r\n\r\nUSERNAME = 'xxxxxxxx'\r\nPASSWORD = 'xxxxxxxx'\r\nCLIENTID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'\r\nSECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\r\nHOST = 'https:\/\/mysite.com\/wallabag\/web'    \r\n\r\n\r\ngettoken = {'username': USERNAME, 'password': PASSWORD, 'client_id': CLIENTID, 'client_secret': SECRET, 'grant_type': 'password'}\r\nprint (gettoken)\r\nr = requests.post('{}\/oauth\/v2\/token'.format(HOST), gettoken)\r\nprint (r.content)\r\n\r\naccess = r.json().get('access_token')\r\n\r\n\r\nurl = 'https:\/\/visited_site.com' # URL of the article\r\n# should the article be already read? 0 or 1 for archive\r\n# should the article be added as favorited? 0 or 1 for starred\r\n\r\narticle = {'url': url, 'archive': 0 , 'starred': 0, 'access_token': access}\r\nr = requests.post('{}\/api\/entries.json'.format(HOST), article)\r\n\r\n\r\n&quot;&quot;&quot;\r\noutput:\r\n{'username': 'xxxxxxxxx', 'password': 'xxxxxxxxxx', 'grant_type': 'password', 'client_id': 'xxxxxxxxxxxxxxx', 'client_secret': 'xxxxxxxxxxx'}\r\nb'{&quot;access_token&quot;:&quot;xxxxxxxxxxxxxx&quot;,&quot;expires_in&quot;:3600,&quot;token_type&quot;:&quot;bearer&quot;,&quot;scope&quot;:null,&quot;refresh_token&quot;:&quot;xxxxxxxxxxxxxx&quot;}'\r\n&quot;&quot;&quot;\r\n\r\n\r\n\r\n<\/pre>\n<h2>Troubleshooting<\/h2>\n<p>I found useful to include print (r.content) in case something goes wrong. It can help see what is returned by sever.<br \/>\nAlso it helped me looking at log which is located at \/var\/logs\/prod.log under yoursite.com\/wallabag. In case something is going wrong it might have some clue in the log. <\/p>\n<h2>Conclusion<\/h2>\n<p>We looked at python api example of how to integrate python script with Wallabag web application and send data using Wallabag API and python requests library. <\/p>\n<p><strong>References<\/strong><\/p>\n<p><a href=\"https:\/\/gist.github.com\/benediktg\/9a29b923235d6c7c2fe6833b240a08ee#file-wallabag-api-example-py\" target=\"_blank\">wallabag api example<\/a><br \/>\n<a href=\"https:\/\/github.com\/wallabag\/wallabag\" target=\"_blank\">Wallabag<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wallabag Many a times it happens that we need to create API to post data to some web application using python framework. To over come this problem of sending data to application from outside of it, using API, I am going to show how you can do this for Wallabag Web Application. Wallabag is Read &#8230; <a title=\"Python API Example with Wallabag Web Application\" class=\"read-more\" href=\"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/\" aria-label=\"More on Python API Example with Wallabag Web Application\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false},"categories":[4,14],"tags":[5,17,16,15],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python API Example with Wallabag Web Application - Using Web API with Python<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python API Example with Wallabag Web Application - Using Web API with Python\" \/>\n<meta property=\"og:description\" content=\"Wallabag Many a times it happens that we need to create API to post data to some web application using python framework. To over come this problem of sending data to application from outside of it, using API, I am going to show how you can do this for Wallabag Web Application. Wallabag is Read ... Read more\" \/>\n<meta property=\"og:url\" content=\"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/\" \/>\n<meta property=\"og:site_name\" content=\"Using Web API with Python\" \/>\n<meta property=\"article:published_time\" content=\"2018-12-25T19:22:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-12-27T02:44:47+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/12\/python-and-wallabag.png\" \/>\n<meta name=\"author\" content=\"owygs156\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"owygs156\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/\",\"url\":\"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/\",\"name\":\"Python API Example with Wallabag Web Application - Using Web API with Python\",\"isPartOf\":{\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/#website\"},\"datePublished\":\"2018-12-25T19:22:36+00:00\",\"dateModified\":\"2018-12-27T02:44:47+00:00\",\"author\":{\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/#\/schema\/person\/6788923b31e0ea6b3bfa2c079adb1332\"},\"breadcrumb\":{\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/api.intelligentonlinetools.com\/diy\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python API Example with Wallabag Web Application\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/#website\",\"url\":\"http:\/\/api.intelligentonlinetools.com\/diy\/\",\"name\":\"Using Web API with Python\",\"description\":\"Using Web API with Python\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/api.intelligentonlinetools.com\/diy\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/#\/schema\/person\/6788923b31e0ea6b3bfa2c079adb1332\",\"name\":\"owygs156\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g\",\"caption\":\"owygs156\"},\"url\":\"http:\/\/api.intelligentonlinetools.com\/diy\/author\/owygs156\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python API Example with Wallabag Web Application - Using Web API with Python","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/","og_locale":"en_US","og_type":"article","og_title":"Python API Example with Wallabag Web Application - Using Web API with Python","og_description":"Wallabag Many a times it happens that we need to create API to post data to some web application using python framework. To over come this problem of sending data to application from outside of it, using API, I am going to show how you can do this for Wallabag Web Application. Wallabag is Read ... Read more","og_url":"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/","og_site_name":"Using Web API with Python","article_published_time":"2018-12-25T19:22:36+00:00","article_modified_time":"2018-12-27T02:44:47+00:00","og_image":[{"url":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/12\/python-and-wallabag.png"}],"author":"owygs156","twitter_card":"summary_large_image","twitter_misc":{"Written by":"owygs156","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/","url":"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/","name":"Python API Example with Wallabag Web Application - Using Web API with Python","isPartOf":{"@id":"http:\/\/api.intelligentonlinetools.com\/diy\/#website"},"datePublished":"2018-12-25T19:22:36+00:00","dateModified":"2018-12-27T02:44:47+00:00","author":{"@id":"http:\/\/api.intelligentonlinetools.com\/diy\/#\/schema\/person\/6788923b31e0ea6b3bfa2c079adb1332"},"breadcrumb":{"@id":"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/api.intelligentonlinetools.com\/diy\/python-api-example-wallabag-web-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/api.intelligentonlinetools.com\/diy\/"},{"@type":"ListItem","position":2,"name":"Python API Example with Wallabag Web Application"}]},{"@type":"WebSite","@id":"http:\/\/api.intelligentonlinetools.com\/diy\/#website","url":"http:\/\/api.intelligentonlinetools.com\/diy\/","name":"Using Web API with Python","description":"Using Web API with Python","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/api.intelligentonlinetools.com\/diy\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/api.intelligentonlinetools.com\/diy\/#\/schema\/person\/6788923b31e0ea6b3bfa2c079adb1332","name":"owygs156","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/api.intelligentonlinetools.com\/diy\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/b351def598609cb4c0b5bca26497c7e5?s=96&d=mm&r=g","caption":"owygs156"},"url":"http:\/\/api.intelligentonlinetools.com\/diy\/author\/owygs156\/"}]}},"_links":{"self":[{"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/posts\/55"}],"collection":[{"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":12,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":70,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/posts\/55\/revisions\/70"}],"wp:attachment":[{"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}