|
| 1 | += Domeapi |
| 2 | +:toc: macro |
| 3 | + |
| 4 | +Ruby client for the Domeapi API. |
| 5 | + |
| 6 | +== Installation |
| 7 | + |
| 8 | +Install the gem and add to the application's Gemfile by executing: |
| 9 | + |
| 10 | +[source,bash] |
| 11 | +---- |
| 12 | +bundle add domeapi |
| 13 | +---- |
| 14 | + |
| 15 | +If bundler is not being used to manage dependencies, install the gem by executing: |
| 16 | + |
| 17 | +[source,bash] |
| 18 | +---- |
| 19 | +gem install domeapi |
| 20 | +---- |
| 21 | + |
| 22 | +== Usage |
| 23 | + |
| 24 | +=== Configuration |
| 25 | + |
| 26 | +Configure the gem with your API key. You can set it via the `DOMEAPI_API_KEY` environment variable or configure it explicitly: |
| 27 | + |
| 28 | +[source,ruby] |
| 29 | +---- |
| 30 | +Rubyists::Domeapi.configure do |config| |
| 31 | + config.api_key = 'your_api_key' |
| 32 | +end |
| 33 | +---- |
| 34 | + |
| 35 | +=== Client |
| 36 | + |
| 37 | +Initialize the client: |
| 38 | + |
| 39 | +[source,ruby] |
| 40 | +---- |
| 41 | +client = Rubyists::Domeapi.client |
| 42 | +---- |
| 43 | + |
| 44 | +=== Polymarket |
| 45 | + |
| 46 | +Access Polymarket endpoints via the `polymarket` namespace. |
| 47 | + |
| 48 | +==== Markets |
| 49 | + |
| 50 | +List markets with optional filtering: |
| 51 | + |
| 52 | +[source,ruby] |
| 53 | +---- |
| 54 | +# List markets with default filter |
| 55 | +markets = client.polymarket.markets.list |
| 56 | +
|
| 57 | +# List markets with custom filter |
| 58 | +filter = Rubyists::Domeapi::Polymarket::MarketFilter.new( |
| 59 | + Rubyists::Domeapi::Polymarket::MarketFilter::Properties.new( |
| 60 | + limit: 10, |
| 61 | + offset: 0, |
| 62 | + status: 'open' |
| 63 | + ) |
| 64 | +) |
| 65 | +markets = client.polymarket.markets.list(filter) |
| 66 | +---- |
| 67 | + |
| 68 | +Get market price: |
| 69 | + |
| 70 | +[source,ruby] |
| 71 | +---- |
| 72 | +price = client.polymarket.markets.price(token_id: 'token_id') |
| 73 | +---- |
| 74 | + |
| 75 | +Get candlesticks: |
| 76 | + |
| 77 | +[source,ruby] |
| 78 | +---- |
| 79 | +candlesticks = client.polymarket.markets.candlesticks( |
| 80 | + condition_id: 'condition_id', |
| 81 | + start_time: 1625097600, |
| 82 | + end_time: 1625184000, |
| 83 | + interval: 60 |
| 84 | +) |
| 85 | +---- |
| 86 | + |
| 87 | +==== Orders |
| 88 | + |
| 89 | +List orders: |
| 90 | + |
| 91 | +[source,ruby] |
| 92 | +---- |
| 93 | +orders = client.polymarket.orders.list( |
| 94 | + market_slug: 'market_slug', |
| 95 | + limit: 10 |
| 96 | +) |
| 97 | +---- |
| 98 | + |
| 99 | +== Development |
| 100 | + |
| 101 | +After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. |
| 102 | + |
| 103 | +To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). |
| 104 | + |
| 105 | +== Contributing |
| 106 | + |
| 107 | +Bug reports and pull requests are welcome on GitHub at https://github.com/bougyman/domeapi. |
0 commit comments