Two of my apps call DataForSEO : ExtensionDash for keyword volumes and Google positions, and the workspace I run my own SEO from. Each had grown its own copy of the HTTP code, and the copies had started to disagree about what an error looks like. So I pulled them out into a gem, dataforseo-ruby .
gem "dataforseo-ruby"
Enter fullscreen mode
Exit fullscreen mode
client = DataForSeo :: Client . new ( login: ENV [ "DATAFORSEO_LOGIN" ], password: ENV [ "DATAFORSEO_PASSWORD" ])
response = client . google_ads_search_volume ( keywords: [ "reverse image search" ], language_code: "en" ) response . items # => [{"keyword" => "reverse image search", "search_volume" => 1500000, ...}] response . cost # => 0.09
Enter fullscreen mode
Exit fullscreen mode
It has no runtime dependencies: net/http , json and zlib from the standard library, Ruby 3.4 or newer. Most of it is about one fact: every request costs money, including the ones that fail.…