Menu

dataforseo-ruby: A Client That Respects the Bill
📰

dataforseo-ruby: A Client That Respects the Bill

DEV Community: ruby·Anton Kopylov·1 day ago
#JKDBNMOG
#devtoruby#devto#dev#client#request
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.