context.dev gem requires Ruby 3.2 or later. SDKs covers the API key and the defaults all SDKs share.
Install
gem "context.dev" to your Gemfile, run bundle install, and run the examples with bundle exec ruby.
Scrape a page
Save this asscrape.rb and run ruby scrape.rb. It prints the page as Markdown, starting with # Example Domain.
scrape.rb
Look up a brand
Replace the request and theputs line with this lookup. It prints the company name.
Notes
- Nested parameters are hashes with
snake_casesymbol keys. brand.retrievetakes the lookup asbody:, because the lookuptypedecides which fields are valid.- Set
timeoutin seconds andmax_retrieson the client:ContextDev::Client.new(timeout: 120, max_retries: 0).