SDKs
Ruby

Ruby SDK

🚧 Coming Soon — The official Ruby SDK is under development. In the meantime, use the REST API directly with any HTTP client.

Using cURL / HTTP

All Orsa endpoints work with standard HTTP requests. Here are examples using Ruby's built-in net/http and the popular faraday gem.

Net::HTTP

require 'net/http'
require 'json'
require 'uri'
 
ORSA_API_KEY = ENV['ORSA_API_KEY']
BASE_URL = 'https://api.orsa.dev'
 
def orsa_get(path, params = {})
  uri = URI("#{BASE_URL}#{path}")
  uri.query = URI.encode_www_form(params) unless params.empty?
 
  request = Net::HTTP::Get.new(uri)
  request['Authorization'] = "Bearer #{ORSA_API_KEY}"
 
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
 
  JSON.parse(response.body)
end
 
def orsa_post(path, body = {})
  uri = URI("#{BASE_URL}#{path}")
 
  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = "Bearer #{ORSA_API_KEY}"
  request['Content-Type'] = 'application/json'
  request.body = body.to_json
 
  response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
    http.request(request)
  end
 
  JSON.parse(response.body)
end
 
# Retrieve brand data
brand = orsa_get('/v1/brand/retrieve', domain: 'stripe.com')
puts brand['data']['name']     # "Stripe"
puts brand['data']['colors']   # ["#635BFF", "#0A2540", "#00D4AA"]
 
# Scrape markdown
page = orsa_get('/v1/web/scrape/markdown', url: 'https://stripe.com/pricing')
puts page['data']['word_count']
 
# AI query
result = orsa_post('/v1/brand/ai/query', {
  domain: 'stripe.com',
  data_to_extract: 'pricing plans with features',
  response_format: 'json'
})
puts result['data']['result']

Faraday

require 'faraday'
require 'json'
 
conn = Faraday.new(url: 'https://api.orsa.dev') do |f|
  f.request :json
  f.response :json
  f.headers['Authorization'] = "Bearer #{ENV['ORSA_API_KEY']}"
end
 
# Retrieve brand
response = conn.get('/v1/brand/retrieve', domain: 'github.com')
brand = response.body
puts brand['data']['name']  # "GitHub"
 
# Scrape images
response = conn.get('/v1/web/scrape/images', url: 'https://github.com')
images = response.body
puts images['count']
 
# Start a crawl
response = conn.post('/v1/web/crawl') do |req|
  req.body = { url: 'https://github.com', maxPages: 20 }
end
puts response.body['jobId']

Error Handling

response = conn.get('/v1/brand/retrieve', domain: 'nonexistent.invalid')
 
case response.status
when 200
  puts response.body['data']
when 400
  puts "Bad request: #{response.body['error']['message']}"
when 401
  puts "Invalid API key"
when 404
  puts "Brand not found"
when 429
  retry_after = response.headers['retry-after']
  puts "Rate limited. Retry in #{retry_after}s"
  sleep(retry_after.to_i)
when 500
  puts "Server error: #{response.body['error']['message']}"
end

Want the Official SDK?

We're building it. If you'd like to contribute or get early access, reach out at hello@orsa.dev or open an issue on GitHub (opens in a new tab).