{"id":21602317,"url":"https://github.com/cryptomkt/cryptomkt-ruby","last_synced_at":"2026-05-09T18:34:50.412Z","repository":{"id":45303779,"uuid":"373907740","full_name":"cryptomkt/cryptomkt-ruby","owner":"cryptomkt","description":"CryptoMarket Ruby SDK ","archived":false,"fork":false,"pushed_at":"2024-03-13T18:28:32.000Z","size":169,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-14T18:47:15.889Z","etag":null,"topics":["bitcoin","cryptomkt","ethereum","ruby","sdk"],"latest_commit_sha":null,"homepage":"https://developers.cryptomkt.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryptomkt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-04T16:56:53.000Z","updated_at":"2024-06-13T03:30:59.556Z","dependencies_parsed_at":"2024-06-13T03:30:57.780Z","dependency_job_id":"d7103ba0-3453-487f-90c6-548f3216276b","html_url":"https://github.com/cryptomkt/cryptomkt-ruby","commit_stats":{"total_commits":7,"total_committers":3,"mean_commits":"2.3333333333333335","dds":0.4285714285714286,"last_synced_commit":"40bbd058aa3ba10fa8adec4a145b99c3b4d6e208"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptomkt%2Fcryptomkt-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptomkt%2Fcryptomkt-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptomkt%2Fcryptomkt-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptomkt%2Fcryptomkt-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptomkt","download_url":"https://codeload.github.com/cryptomkt/cryptomkt-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244228474,"owners_count":20419424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitcoin","cryptomkt","ethereum","ruby","sdk"],"created_at":"2024-11-24T19:12:49.057Z","updated_at":"2026-05-09T18:34:45.385Z","avatar_url":"https://github.com/cryptomkt.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CryptoMarket-Ruby\n\n[main page](https://www.cryptomkt.com/)\n\n[sign up in CryptoMarket](https://www.cryptomkt.com/account/register).\n\n# Installation\n\nTo install Cryptomarket use gem\n\n```\ngem install cryptomarket-sdk -v 3.3.0\n```\n\n# Documentation\n\nThis sdk makes use of the [api version 3](https://api.exchange.cryptomkt.com/) of cryptomarket\n\n# Quick Start\n\n## rest client\n\n```ruby\nrequire \"cryptomarket-sdk\"\n\n# instance a client\napi_key='AB32B3201'\napi_secret='21b12401'\nclient = Cryptomarket::Client.new api_key:api_key, api_secret:api_secret\n\n# get currencies\ncurrencies = client.get_currencies\n\n# get order books\norder_book = client.get_orderbooks symbols:['EOSETH']\n\n# get your account balances\naccount_balance = client.get_wallet_balances\n\n# get your trading balances\ntrading_balance = client.get_spot_trading_balances\n\n# move balance from account bank to account trading\nresult = @client.transfer_between_wallet_and_exchange(\n  currency: \"CRO\",\n  amount: \"0.1\",\n  source:\"wallet\",\n  destination:\"spot\",\n)\n\n# get your active orders\norders = client.get_all_active_spot_orders('EOSETH')\n\n# create a new order\norder = client.create_spot_order(\n  symbol:'EOSETH',\n  side:'buy',\n  quantity:'10',\n  order_type:args.ORDER_TYPE.MARKET\n)\n```\n\n## Websocket Clients\n\nAhere are three websocket clients, the `MarketDataClient`, the `TradingClient` and the `WalletClient`. The `MarketDataClient` is public, while the others require authentication to be used.\n\nAll websocket methods take Procs for their callbacks. These procs take two argument, the first is a possible error in the call (such as missing arguments), and the result data of the method.\n\nSubscriptions also take in a Proc of two parameters, the notification data, and the notification type. The notification type is of type Args::NotificationType, and is either SNAPSHOT, NOTIFICATION or DATA, corresponding to the strings 'snapshot', 'update' and 'data'\n\nThe documentation of a specific subscriptions explains with of this types of notification uses.\n\n### Websocket Market Data Client\n\nThere are no unsubscriptions methods for the `MarketDataClient`. To stop recieving messages is recomended to close the `MarketDataClient`.\n\n```ruby\n# instance a client\nclient = Cryptomarket::Websocket::MarketDataClient.new\nclient.connect\n# close the client\nclient.close\n# subscribe to public trades\nclient.subscribe_to_trades(\n  callback:Proc.new {|notification, type|\n    if type == Args::NotificationType::UPDATE\n      puts \"an update\"\n    end\n    if type == Args::NotificationType::SNAPSHOT\n      puts \"a snapshot\"\n    end\n    puts notification\n  },\n  symbols:['eoseth', 'ethbtc'],\n  limit:2,\n  result_callback:Proc.new {|err, result|\n    if not err.nil?\n      puts err\n    else\n      puts result\n    end\n  }\n)\n\n# subscribe to symbol tickers\nclient.subscribe_to_ticker(\n  speed:\"1s\",\n  callback:Proc.new {|notificatoin, type|\n    if type == Args::NotificationType::DATA\n      puts \"is always data\"\n    end\n    puts notification\n  },\n  symbols:['eoseth', 'ethbtc'],\n  result_callback:Proc.new {|err, result|\n    if not err.nil?\n      puts err\n    else\n      puts result\n    end\n  }\n)\n```\n\n### Websocket Trading Client\n\nSubscription callback to spot trading balances takes only one argument, a list of balances (see example below)\n\n```ruby\n# instance a client with a 15 seconds window\nclient = Cryptomarket::Websocket::TradingClient.new(\n  api_key:Keyloader.api_key,\n  api_secret:Keyloader.api_secret,\n  window:15_000\n)\nclient.connect\n# close the client\nclient.close\n\n# subscribe to order reports\nclient.subscribe_to_reports(\n  callback:Proc.new {|notification, type|\n      if type == Args::NotificationType::UPDATE\n        puts \"a lonely report in a list\"\n      end\n      if type == 'snapshot' # same as Args::NotificationType::SNAPSHOT\n        puts \"reports of active orders\"\n      end\n      puts notification\n  }\n)\n# unsubscribe from order reports\nclient.unsubscribe_to_reports\n\n@wsclient.subscribe_to_spot_balance(\n  callback: -\u003e(balances) {puts balances},\n  result_callback: -\u003e(_) {},\n  mode: 'updates'\n)\n\nclient_order_id = Time.now.to_i.to_s\n\n# create an order\nclient.create_spot_order(\n  symbol: symbol,\n  price:'10000',\n  quantity:'0.01',\n  side:'sell',\n  clientOrderId:client_order_id\n)\n\n# candel an order\nclient.cancel_spot_order(client_order_id)\n\n```\n\n### Websocket Wallet Management Client\n\nSubscription callback to transactions takes only one argument, a transaction (see example below)\n\n```ruby\n# instance a client with a default window of 10 seconds\nclient = Cryptomarket::Websocket::WalletClient.new api_key:Keyloader.api_key, api_secret:Keyloader.api_secret\nclient.connect\n# close the client\ndefer client.close\n\n# subscribe to wallet transactions\ndef callback(transaction):\n  -\u003e(transaction) { puts(transaction) }\n\nclient.subscribe_to_transactions(callback)\n\n# unsubscribe from wallet transactions\nclient.unsubscribe_to_transactions(lambda { |is_success| \n  puts('successful unsubscription') if is_success\n})\n\n# get wallet balances\nclient.get_wallet_balances(-\u003e(balances){ puts balances})\n```\n\n## exception handling\n\n```ruby\nrequire \"cryptomarket-sdk\"\n\nclient = Cryptomarket::Client.new api_key:api_key, api_secret:api_secret\n\n# catch a wrong argument\nbegin\n    order = client.create_spot_order(\n        symbol='EOSETH',\n        side='selllll', # wrong\n        quantity='3'\n    )\nrescue Cryptomarket::SDKException =\u003e e:\n    puts e\nend\n\n# catch a failed transaction\nbegin\n    order = client.create_spot_order(\n        symbol='eosehtt',  # non existant symbol\n        side='sell',\n        quantity='10',\n    )\nrescue Cryptomarket::SDKException =\u003e e:\n    puts e\nend\n\nwsclient = Cryptomarket::Websocket::TradingClient.new api_key:api_key, api_secret:api_secret\n\n# websocket errors are passed as the first argument to the callback. valid for all non subscription methods\nmy_callback = Proc.new {|err, data|\n    if not err.nil?\n        puts err # deal with error\n        return\n    end\n    puts data\n}\n\nwsclient.get_spot_trading_balances(my_callback)\n\n# catch authorization error\n# to catch an authorization error on client connection, a on_error function must be defined on the client\nwsclient = TradingClient(api_key, api_secret)\nwsclient.onerror = Proc.new {|error| puts \"error\", error}\nwsclient.connect\n```\n\n# Checkout our other SDKs\n\n[node sdk](https://github.com/cryptomkt/cryptomkt-node)\n\n[java sdk](https://github.com/cryptomkt/cryptomkt-java)\n\n[go sdk](https://github.com/cryptomkt/cryptomkt-go)\n\n[python sdk](https://github.com/cryptomkt/cryptomkt-python)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptomkt%2Fcryptomkt-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptomkt%2Fcryptomkt-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptomkt%2Fcryptomkt-ruby/lists"}