Skip to content

Instantly share code, notes, and snippets.

@barryf
Created March 31, 2023 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryf/5d4fbc563cbeffe31759f6db4b6cd1a6 to your computer and use it in GitHub Desktop.
Save barryf/5d4fbc563cbeffe31759f6db4b6cd1a6 to your computer and use it in GitHub Desktop.
Transfer Read Later JSON export from Reeder to Readwise Reader via its API. Batches posts because of API's 20 requests per minute rate limit.
# Transfer Read Later JSON export from Reeder to Readwise Reader via its API.
# Batches posts because of API's 20 requests per minute rate limit.
require 'json'
require 'httparty'
offset = 0
max = 20
token = ENV['token']
api_url = 'https://readwise.io/api/v3/save/'
f = File.read('ReadLater.json')
links = JSON.parse(f)
for i in offset...links.size do
res = HTTParty.post(api_url, {
body: { "url" => links[i]['link'] }.to_json,
headers: {
"Content-Type" => "application/json",
"Authorization" => "Token #{token}"
}
})
puts "#{i} - #{res.body}"
sleep(61) if (i + 1) % max == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment