Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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