Skip to content

Instantly share code, notes, and snippets.

@sergio1990
Created March 7, 2014 10:48
Show Gist options
  • Save sergio1990/9409385 to your computer and use it in GitHub Desktop.
Save sergio1990/9409385 to your computer and use it in GitHub Desktop.
Sample requesting information from API-NG betfair
require 'net/http'
require 'uri'
app_key = "YOUR_APP_KEY"
session_key = "YOUR_SESSION_ID"
uri = URI.parse("https://api-ng.betstores.com/betting/betfair/services/api.betfair.com/exchange/betting/json-rpc/v1")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
request.body = "{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/listCompetitions\", \"params\": {\"filter\": { }}}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["X-Application"] = app_key
request["X-Authentication"] = session_key
response = http.request request
puts response.body
{"jsonrpc":"2.0","error":{"code":-32700,"message":"DSC-0008"}}
{"jsonrpc":"2.0","result":[{"competition":{"id":"892425","name":"Czech 3. Liga"},"marketCount":40,"competitionRegion":"CZE"}, ...]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment