{"id":13,"date":"2018-01-16T02:03:05","date_gmt":"2018-01-16T02:03:05","guid":{"rendered":"http:\/\/api.intelligentonlinetools.com\/diy\/?p=13"},"modified":"2018-02-01T02:16:20","modified_gmt":"2018-02-01T02:16:20","slug":"web-api-save-pocket-app-instapaper-app","status":"publish","type":"post","link":"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/","title":{"rendered":"Web API to Save to Pocket App and Instapaper App"},"content":{"rendered":"<p>As we surf the web we find a lot of information that we might use later. We use different applications (Pocket app, Instapaper, Diigo, Evernote or other apps) to save links or notes what we find.<\/p>\n<p>While many of the above applications have a lot of great features there still a lot of opportunities to automate some processes using web API that many of applications provide now.<\/p>\n<p>This will allow to extend application functionality and eliminate some manual processes.<\/p>\n<p>For Example: You have about 20 links that you want to send to pocket like application.<br \/>\nAnother example: When you add link to one application you may be want also save link or note to Pocket app or to Instapaper application.<br \/>\nOr may be you want automatically (through script) extract links from some web sites and save them to your Pocket app.<\/p>\n<p>In today post we will look at few examples that allow you start to do this. We will check how to use Pocket API and Instapaper API with python programming.<\/p>\n<h3>API for Pocket App<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/01\/pocket.jpg\" alt=\"pocket API\" width=\"56\" height=\"51\" class=\"alignnone size-full wp-image-21\"  style=\"float:left\" \/> Pocket, previously known as Read It Later, is an application and service for managing a reading list of articles from the Internet. It is available on many different devices including web browsers. (Wikipedia)<br \/>\nThere is great post[1] that is showing how to set up API for it. This post has detailed screenshots how to get all the needed identification information for successful login.<\/p>\n<p>In summary you need get online consumer key for your api application then obtain token code via script. Then you can access the link that will include token and do authorization of application. After this you can use API for sending links.<\/p>\n<p>Below is the summary python script to send the link to Pocket app including previous steps:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport requests\r\n\r\n# can be any for link\r\nredirect_link = &quot;google.com&quot;\r\nconsumer_key=&quot;xxxxxxxx&quot;\r\n# obtain consume key online\r\n#connect to pocket API to get token code\r\npocket_api = requests.post('https:\/\/getpocket.com\/v3\/oauth\/request',\r\n         data = {'consumer_key':consumer_key,\r\n                 'redirect_uri':redirect_link})\r\n\r\npocket_api.status_code       #if 200, it means all ok.\r\n\r\nprint(pocket_api.headers)               \r\nprint (pocket_api.text)\r\n\r\n#remove 'code='\r\ntoken= pocket_api.text[5:]\r\nprint (token)\r\nurl=&quot;https:\/\/getpocket.com\/auth\/authorize?request_token=&quot; + token + &quot;&amp;redirect_uri=&quot; + redirect_link \r\n\r\nimport webbrowser\r\nwebbrowser.open_new(url) # opens in default browser\r\n#click on Authorize button in webbrowser\r\n\r\n# Once authoration done you can post as below (need uncomment code below)  \r\n&quot;&quot;&quot;\r\npocket_add = requests.post('https:\/\/getpocket.com\/v3\/add',\r\n       data= {'url': 'https:\/\/getpocket.com\/developer\/apps\/new',\r\n              'consumer_key':consumer_key,\r\n              'access_token': token})\r\nprint (pocket_add.status_code)\r\n\r\n&quot;&quot;&quot;\r\n<\/pre>\n<h3>API for Instapaper<\/h3>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/01\/Instapaper.jpg\" alt=\"\" width=\"30\" height=\"47\" class=\"alignnone size-full wp-image-20\" style=\"float:left\" \/> Instapaper is a bookmarking service owned by Pinterest. It allows web content to be saved so it can be &#8220;read later&#8221; on a different device, such as an e-reader, smartphone, tablet. (Wikipedia)<br \/>\nBelow is the code example how to send link to Instapaper. The code example is based on the script that I found on Internet [2]<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport urllib, sys\r\n\r\ndef error(msg):\r\nsys.exit(msg)\r\n\r\ndef main():\r\napi = 'https:\/\/www.instapaper.com\/api\/add'\r\n\r\nparams = urllib.parse.urlencode({\r\n'username' : &quot;actual_user_name&quot;,\r\n'password' : &quot;actual_password&quot;,\r\n'url' : &quot;https:\/\/www.actual_url&quot;,\r\n'title' : &quot;actual_title&quot;,\r\n'selection' : &quot;description&quot;\r\n\r\n}).encode(&quot;utf-8&quot;)\r\n\r\nr = urllib.request.urlopen(api, params)\r\n\r\nstatus = r.getcode()\r\n\r\nif status == 201:\r\n\r\nprint('%s saved as %s' % (r.headers['Content-Location'], r.headers['X-Instapaper-Title']))\r\nelif status == 400:\r\nerror('Status 400: Bad request or exceeded the rate limit. Probably missing a required parameter, such as url.')\r\nelif status == 403:\r\nerror('Status 403: Invalid username or password.')\r\nelif status == 500:\r\nerror('Status 500: The service encountered an error. Please try again later')\r\n\r\nif __name__ == '__main__':\r\nmain()\r\n<\/pre>\n<p><strong>References<\/strong><br \/>\n1. <a href=http:\/\/saideepchandg.github.io\/pocket\/2016\/02\/21\/add-pocket-api-to-your-site.html target=\"_blank\">Add Pocket API using Python &#8211; Tutorial<\/a><br \/>\n2. <a href=https:\/\/gist.github.com\/sliem\/1289424 target=\"_blank\">Instapaper<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we surf the web we find a lot of information that we might use later. We use different applications (Pocket app, Instapaper, Diigo, Evernote or other apps) to save links or notes what we find. While many of the above applications have a lot of great features there still a lot of opportunities to &#8230; <a title=\"Web API to Save to Pocket App and Instapaper App\" class=\"read-more\" href=\"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/\" aria-label=\"More on Web API to Save to Pocket App and Instapaper App\">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],"tags":[5,8,7,9,6],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Web API to Save to Pocket App and Instapaper App with Python<\/title>\n<meta name=\"description\" content=\"Web API to save link to Pocket App and to Instapaper App via python script. The post contains source code detailed examples that will help to start with automation the tasks associated with the above Pocket or Instapaper applications\" \/>\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\/web-api-save-pocket-app-instapaper-app\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Web API to Save to Pocket App and Instapaper App with Python\" \/>\n<meta property=\"og:description\" content=\"Web API to save link to Pocket App and to Instapaper App via python script. The post contains source code detailed examples that will help to start with automation the tasks associated with the above Pocket or Instapaper applications\" \/>\n<meta property=\"og:url\" content=\"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/\" \/>\n<meta property=\"og:site_name\" content=\"Using Web API with Python\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-16T02:03:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-02-01T02:16:20+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/01\/pocket.jpg\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/\",\"url\":\"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/\",\"name\":\"Web API to Save to Pocket App and Instapaper App with Python\",\"isPartOf\":{\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/#website\"},\"datePublished\":\"2018-01-16T02:03:05+00:00\",\"dateModified\":\"2018-02-01T02:16:20+00:00\",\"author\":{\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/#\/schema\/person\/6788923b31e0ea6b3bfa2c079adb1332\"},\"description\":\"Web API to save link to Pocket App and to Instapaper App via python script. The post contains source code detailed examples that will help to start with automation the tasks associated with the above Pocket or Instapaper applications\",\"breadcrumb\":{\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/api.intelligentonlinetools.com\/diy\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web API to Save to Pocket App and Instapaper App\"}]},{\"@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":"Web API to Save to Pocket App and Instapaper App with Python","description":"Web API to save link to Pocket App and to Instapaper App via python script. The post contains source code detailed examples that will help to start with automation the tasks associated with the above Pocket or Instapaper applications","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\/web-api-save-pocket-app-instapaper-app\/","og_locale":"en_US","og_type":"article","og_title":"Web API to Save to Pocket App and Instapaper App with Python","og_description":"Web API to save link to Pocket App and to Instapaper App via python script. The post contains source code detailed examples that will help to start with automation the tasks associated with the above Pocket or Instapaper applications","og_url":"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/","og_site_name":"Using Web API with Python","article_published_time":"2018-01-16T02:03:05+00:00","article_modified_time":"2018-02-01T02:16:20+00:00","og_image":[{"url":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-content\/uploads\/2018\/01\/pocket.jpg"}],"author":"owygs156","twitter_card":"summary_large_image","twitter_misc":{"Written by":"owygs156","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/","url":"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/","name":"Web API to Save to Pocket App and Instapaper App with Python","isPartOf":{"@id":"http:\/\/api.intelligentonlinetools.com\/diy\/#website"},"datePublished":"2018-01-16T02:03:05+00:00","dateModified":"2018-02-01T02:16:20+00:00","author":{"@id":"http:\/\/api.intelligentonlinetools.com\/diy\/#\/schema\/person\/6788923b31e0ea6b3bfa2c079adb1332"},"description":"Web API to save link to Pocket App and to Instapaper App via python script. The post contains source code detailed examples that will help to start with automation the tasks associated with the above Pocket or Instapaper applications","breadcrumb":{"@id":"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/api.intelligentonlinetools.com\/diy\/web-api-save-pocket-app-instapaper-app\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/api.intelligentonlinetools.com\/diy\/"},{"@type":"ListItem","position":2,"name":"Web API to Save to Pocket App and Instapaper App"}]},{"@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\/13"}],"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=13"}],"version-history":[{"count":8,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":25,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/posts\/13\/revisions\/25"}],"wp:attachment":[{"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/api.intelligentonlinetools.com\/diy\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}