crawlfetch

Ruby on Rails: download YouTube, TikTok and Instagram videos

In Rails, a plain Ruby service object calls CrawlFetch, and an ActiveJob attaches the downloaded file to an Active Storage record.

How it fits together

Controllers enqueue a job with the source URL; the job resolves it, downloads the file and attaches it — users never wait on a large download.

Ruby on Rails example

require "open-uri"
class SaveVideoJob < ApplicationJob
retry_on Net::HTTPError, wait: :polynomially_longer, attempts: 5
def perform(video)
data = CrawlFetch.resolve(video.source_url) # see the Ruby guide for the client
URI.parse(data["downloadUrl"]).open do |io|
video.file.attach(io: io, filename: "#{data["id"]}.mp4", content_type: "video/mp4")
end
video.update!(title: data["title"])
end
end

Notes for Ruby on Rails

  • Store the key in Rails credentials: Rails.application.credentials.crawlfetch_key.
  • Use Solid Queue or Sidekiq for the job backend.

FAQ

Where is the CrawlFetch client?

Copy the resolve method from the Ruby guide into app/services/crawl_fetch.rb.

Related

Last updated 2026-10-25

Add video downloads to your product today.

1,000 credits on signup plus 500 every month. That is roughly 180 YouTube clips to start, with no card.

Create free account