April 25, 2024 |
permanent
Summary #
mobile and web app to collect readable from internet.
Getting auth token with Python #
(pyvenv-workon "test_env")
print("check")
print("check")
import json
import requests
from urllib.parse import urlencode
from urllib.request import Request, urlopen
# POST request for token
url = 'https://getpocket.com/v3/oauth/request' # Set destination URL here
post_fields = {"consumer_key":"101788-5cf43fa78a10829bfff062d","redirect_uri":"http://www.google.com"}
# Set POST fields here
request = Request(url, urlencode(post_fields).encode())
json = urlopen(request).read().decode()
print(json)
Complete example to get access-token and add a url with title and tag to pocket #
import requests
import webbrowser
import json
import datetime
consumer_key = "110830-22cdf5e727a62bac14d6d72"
call_back_url = "https://google.com"
def add_url_to_pocket(url, title, access_token):
# https://getpocket.com/developer/docs/v3/add
headers = {
"Content-Type": "application/json; charset=UTF-8",
"X-Accept": "application/json",
}
data = {
"url": url,
"title": title,
"tags": ["jak-notes"],
"time": datetime.datetime.now().timestamp(),
"consumer_key": consumer_key,
"access_token": access_token,
}
print("data")
print(data)
response = requests.post(
"https://getpocket.com/v3/add", headers=headers, data=json.dumps(data)
)
return response
def get_pocket_auth_code(consumer_key, redirect_uri):
# https://getpocket.com/developer/docs/authentication
headers = {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Accept": "application/x-www-form-urlencoded",
}
data = {"consumer_key": consumer_key, "redirect_uri": redirect_uri}
response = requests.post(
"https://getpocket.com/v3/oauth/request", headers=headers, data=data
)
if response.status_code == 200:
return response.text.split("=")[1]
else:
return "Error: unable to get access token"
def get_access_token(consumer_key, auth_code):
headers = {
"Content-Type": "application/json; charset=UTF-8",
"X-Accept": "application/json",
}
data = {"consumer_key": consumer_key, "code": auth_code}
response = requests.post(
"https://getpocket.com/v3/oauth/authorize",
headers=headers,
data=json.dumps(data),
)
if response.status_code == 200:
response_json = response.json()
return response_json.get("access_token")
return response
def get_url_authorize_pocket(auth_code):
url = f"https://getpocket.com/auth/authorize?request_token={auth_code}&redirect_uri={call_back_url}"
return url
def run_google_chrome(url):
webbrowser.open(url)
auth_code = get_pocket_auth_code(consumer_key, call_back_url)
print("auth_code")
print(auth_code)
url = get_url_authorize_pocket(auth_code)
print("url")
print(url)
run_google_chrome(url)
# wait until the user authorizes the application
input("Press Enter after you have authorized the application")
access_token = get_access_token(consumer_key, auth_code)
print("access_token")
print(access_token)
response = add_url_to_pocket("https://jaaved.netlify.app/", "Home", access_token)
print("response")
print(response)
Rate limiting #
ref..
- Each user is limited to 320 calls per hour.
- Each application is limited to 10,000 calls per hour.
references #
https://getpocket.com/developer/docs/authentication https://getpocket.com/developer/docs/v3/add https://www.jamesfmackenzie.com/getting-started-with-the-pocket-developer-api/
Shortcut #
- Pocket current page: Command + Shfit + p
- Activate pocket: CMD + Shift + l
Premium Features #

Why I bought premium account? #
- Full text search
- search with tags possible with Full Text Search only ref #ocr -> to search for tags
- tag suggestion
- Save forever
After purchasing message #
Order number: sub_1P9N0s2pAwZkQhr2Nvzy3rY9
Monthly 5$ subscription
OCR of Images #
2024-04-25_10-42-17_screenshot.png #

SAVE 25% POCKET Free Account PREMIUM Annual Membership PREMIUM Monthly Membership $44.99/year $4.99/month V Save, read, watch & listen V Save, read, watch & listen V Permanent library of everything you've saved V Suggested tags V Full-text search V Unlimited highlights V Premium fonts V Save, read, watch & listen V Permanent library of everything you've saved V Suggested tags V Full-text search V Unlimited highlights V Premium fonts See your list Select this option Select this option
2024-04-25_10-47-29_screenshot.png #

Hooray! You're officially a Pocket Premium member. Welcome to the new ad-free, customizable, permanent version of your Pocket. We think you'll * a like it here. Your order number is sub_ 1P9NOs2pAwZKQhr2Nvzy3rY9. We'll send a d confirmation email shortly. h Please note that it may take a moment for your account to reflect its premium status. Go to my list
OCR of Images #
2024-04-25_10-42-17_screenshot.png #

SAVE 25% POCKET Free Account PREMIUM Annual Membership PREMIUM Monthly Membership $44.99/year $4.99/month V Save, read, watch & listen V Save, read, watch & listen V Permanent library of everything you've saved V Suggested tags V Full-text search V Unlimited highlights V Premium fonts V Save, read, watch & listen V Permanent library of everything you've saved V Suggested tags V Full-text search V Unlimited highlights V Premium fonts See your list Select this option Select this option
2024-04-25_10-47-29_screenshot.png #

Hooray! You're officially a Pocket Premium member. Welcome to the new ad-free, customizable, permanent version of your Pocket. We think you'll * a like it here. Your order number is sub_ 1P9NOs2pAwZKQhr2Nvzy3rY9. We'll send a d confirmation email shortly. h Please note that it may take a moment for your account to reflect its premium status. Go to my list