cryptsy-api2 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDk0ZTg3MTVmNjJjMTQ1YjJlNGFiODY1ZTUzOTQzOGQwZGJiYjFhMA==
5
+ data.tar.gz: !binary |-
6
+ NmZjYjZmZWYwYjFiYzY4Nzg1OTY1MzcwOWRlNGRlMmRlZjgxNmYzYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MzIzMTMyYmNjMDNlNzk3ODRmZTdiODQzNzYwNTNjZDgwZTI4YWJiYTBiYjJk
10
+ NmEwODA2NDRiODZhODYzY2Y0ZDFhZjgzMzlkMWFjZGIwMzg0NmVlZjYxYmZl
11
+ MTEwYTZhOTRmY2RlNjdiMWIyZjJjNDE1ZDZmYzUyOTRkY2QzMTA=
12
+ data.tar.gz: !binary |-
13
+ MDUzMjE5ZWEzMzI5NDUwY2NlM2I4ODE2ODI5YjYzMTlhNWU4NjQ4NGJlNTQ4
14
+ NzZiMDgwNmM0OWM1NTgxOTNiMWMyOWMzODkyZjMxYTViZDk3MTFhYTE2YjE1
15
+ YmYyMTUzODlhMmI1YjllMzVhZmY0OWYyNzdlZWI4N2I4NjE1NDc=
@@ -0,0 +1,22 @@
1
+ module Cryptsy
2
+ module API2
3
+ class Converter
4
+ def initialize(public_key=nil, private_key=nil)
5
+ @public_key = public_key
6
+ @private_key = private_key
7
+ end
8
+
9
+ def create(options)
10
+ Request.send("converter", options, @public_key, @private_key, "POST")
11
+ end
12
+
13
+ def info(quote_id)
14
+ Request.send("converter/#{quote_id}", {}, @public_key, @private_key)
15
+ end
16
+
17
+ def depositaddress(quote_id)
18
+ Request.send("converter/#{quote_id}/depositaddress", {}, @public_key, @private_key)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ module Cryptsy
2
+ module API2
3
+ class Currencies
4
+ def initialize(public_key=nil, private_key=nil)
5
+ @public_key = public_key
6
+ @private_key = private_key
7
+ end
8
+
9
+ def list
10
+ Request.send("currencies")
11
+ end
12
+
13
+ def info(currency_id)
14
+ Request.send("currencies/#{currency_id}")
15
+ end
16
+
17
+ # Need extra special access for these, think about testing later?
18
+ #
19
+ # def status(currency_id)
20
+ # Request.send("currencies/#{currency_id}/status", {}, @public_key, @private_key)
21
+ # end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,50 @@
1
+ module Cryptsy
2
+ module API2
3
+ class Markets
4
+ def initialize(public_key=nil, private_key=nil)
5
+ @public_key = public_key
6
+ @private_key = private_key
7
+ end
8
+
9
+ def list
10
+ Request.send("markets")
11
+ end
12
+
13
+ def info(market_id)
14
+ Request.send("markets/#{market_id}")
15
+ end
16
+
17
+ def volume(market_id=nil)
18
+ path = "markets/volume"
19
+ path = "markets/#{market_id}/volume" unless market_id.nil?
20
+ Request.send(path)
21
+ end
22
+
23
+ def ticker(market_id=nil)
24
+ path = "markets/ticker"
25
+ path = "markets/#{market_id}/ticker" unless market_id.nil?
26
+ Request.send(path)
27
+ end
28
+
29
+ def fees(market_id)
30
+ Request.send("markets/#{market_id}/fees", {}, @public_key, @private_key)
31
+ end
32
+
33
+ def triggers(market_id)
34
+ Request.send("markets/#{market_id}/triggers", {}, @public_key, @private_key)
35
+ end
36
+
37
+ def orderbook(market_id, options={})
38
+ Request.send("markets/#{market_id}/orderbook", options)
39
+ end
40
+
41
+ def tradehistory(market_id, options={})
42
+ Request.send("markets/#{market_id}/tradehistory", options)
43
+ end
44
+
45
+ def ohlc(market_id, options={})
46
+ Request.send("markets/#{market_id}/ohlc", options)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,24 @@
1
+ module Cryptsy
2
+ module API2
3
+ class Order
4
+ def initialize(public_key=nil, private_key=nil)
5
+ @public_key = public_key
6
+ @private_key = private_key
7
+ end
8
+
9
+ # Required Options:
10
+ # { marketid: 0, ordertype: 'buy|sell', quantity: 0.00, price: 0.00 }
11
+ def create(options)
12
+ Request.send("order", options, @public_key, @private_key, "POST")
13
+ end
14
+
15
+ def info(order_id)
16
+ Request.send("order/#{order_id}", {}, @public_key, @private_key)
17
+ end
18
+
19
+ def delete(order_id)
20
+ Request.send("order/#{order_id}", {}, @public_key, @private_key, "DELETE")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ module Cryptsy
2
+ module API2
3
+ class Trigger
4
+ def initialize(public_key=nil, private_key=nil)
5
+ @public_key = public_key
6
+ @private_key = private_key
7
+ end
8
+
9
+ def create(options)
10
+ Request.send("trigger", options, @public_key, @private_key, "POST")
11
+ end
12
+
13
+ def info(trigger_id)
14
+ Request.send("trigger/#{trigger_id}", {}, @public_key, @private_key)
15
+ end
16
+
17
+ def delete(trigger_id)
18
+ Request.send("trigger/#{trigger_id}", {}, @public_key, @private_key, "DELETE")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,80 @@
1
+ module Cryptsy
2
+ module API2
3
+ class User
4
+ # TODO: string to id conversion for currency_id
5
+
6
+ def initialize(public_key=nil, private_key=nil)
7
+ @public_key = public_key
8
+ @private_key = private_key
9
+ end
10
+
11
+ def info
12
+ Request.send("info", {}, @public_key, @private_key)
13
+ end
14
+
15
+ def balances(currency_id=nil, options={})
16
+ path = "balances"
17
+ path += "/#{currency_id}" unless currency_id.nil?
18
+ Request.send(path, options, @public_key, @private_key)
19
+ end
20
+
21
+ def deposits(currency_id=nil, options={})
22
+ path = "deposits"
23
+ path += "/#{currency_id}" unless currency_id.nil?
24
+ Request.send(path, options, @public_key, @private_key)
25
+ end
26
+
27
+ def addresses(currency_id=nil, options={})
28
+ path = "addresses"
29
+ path += "/#{currency_id}" unless currency_id.nil?
30
+ Request.send(path, options, @public_key, @private_key)
31
+ end
32
+
33
+ def orders(currency_id=nil, options={})
34
+ path = "orders"
35
+ path += "/#{currency_id}" unless currency_id.nil?
36
+ Request.send(path, options, @public_key, @private_key)
37
+ end
38
+
39
+ def triggers(currency_id=nil, options={})
40
+ path = "triggers"
41
+ path += "/#{currency_id}" unless currency_id.nil?
42
+ Request.send(path, options, @public_key, @private_key)
43
+ end
44
+
45
+ def tradehistory(options={})
46
+ Request.send("tradehistory", options, @public_key, @private_key)
47
+ end
48
+
49
+ def validatetradekey(tradekey)
50
+ Request.send("validatetradekey", { tradekey: tradekey }, @public_key, @private_key)
51
+ end
52
+
53
+ def transfers(currency_id=nil, options={})
54
+ path = "transfers"
55
+ path += "/#{currency_id}" unless currency_id.nil?
56
+ Request.send(path, options, @public_key, @private_key)
57
+ end
58
+
59
+ def withdrawals(currency_id=nil, options={})
60
+ path = "withdrawals"
61
+ path += "/#{currency_id}" unless currency_id.nil?
62
+ Request.send(path, options, @public_key, @private_key)
63
+ end
64
+
65
+ # Need extra special access for these, think about testing later?
66
+ #
67
+ # def transfer(currency_id, options)
68
+ # path = "transfer"
69
+ # path += "/#{currency_id}" unless currency_id.nil?
70
+ # Request.send(path, options, @public_key, @private_key)
71
+ # end
72
+ #
73
+ # def withdraw(currency_id, options)
74
+ # path = "withdraw"
75
+ # path += "/#{currency_id}" unless currency_id.nil?
76
+ # Request.send(path, options, @public_key, @private_key)
77
+ # end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,69 @@
1
+ require 'bundler/setup'
2
+ Bundler.require
3
+
4
+
5
+ require 'httparty'
6
+ require 'json'
7
+ require 'openssl'
8
+ require 'uri'
9
+
10
+ require_relative 'api2/converter'
11
+ require_relative 'api2/currencies'
12
+ require_relative 'api2/markets'
13
+ require_relative 'api2/order'
14
+ require_relative 'api2/trigger'
15
+ require_relative 'api2/user'
16
+
17
+ module Cryptsy
18
+ module API2
19
+ class Client
20
+ attr_accessor :user, :markets, :currencies, :order, :converter, :trigger
21
+
22
+ def initialize(public_key=nil, private_key=nil)
23
+ @user = User.new(public_key, private_key)
24
+ @markets = Markets.new(public_key, private_key)
25
+ @currencies = Currencies.new(public_key, private_key)
26
+ @order = Order.new(public_key, private_key)
27
+ @converter = Converter.new(public_key, private_key)
28
+ @trigger = Trigger.new(public_key, private_key)
29
+ end
30
+ end
31
+
32
+ class Request
33
+ def self.send(path, query={}, public_key=nil, private_key=nil, method="GET")
34
+ auth = !public_key.nil? && !private_key.nil?
35
+ url = "https://api.cryptsy.com/api/v2/#{path}"
36
+ query[:nonce] = nonce if auth
37
+ options = URI.encode_www_form(query) unless query.empty?
38
+ headers = {}
39
+ headers["Sign"] = sign(query, private_key) if auth
40
+ headers["Key"] = public_key if auth
41
+ case method
42
+ when "POST"
43
+ response = HTTParty.post(url, headers: headers, body: query)
44
+ when "DELETE"
45
+ response = HTTParty.delete(url, headers: headers, body: query)
46
+ else
47
+ response = HTTParty.get(url, headers: headers, query: query)
48
+ end
49
+
50
+ return JSON.parse(response.body)
51
+ end
52
+
53
+ private
54
+
55
+ def self.nonce
56
+ (Time.now.to_f * 1000).round
57
+ end
58
+
59
+ def self.sign(query, private_key=nil)
60
+ OpenSSL::HMAC.hexdigest(
61
+ OpenSSL::Digest.new('sha512'),
62
+ private_key.encode('utf-8'),
63
+ URI.encode( query.map{ |k,v| "#{k}=#{v}" }.join("&") )
64
+ )
65
+ end
66
+ end
67
+
68
+ end
69
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cryptsy-api2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.2
5
+ platform: ruby
6
+ authors:
7
+ - Alex Hanna
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby library for Cryptsy API v2
14
+ email: tinnvec@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/cryptsy/api2.rb
20
+ - lib/cryptsy/api2/converter.rb
21
+ - lib/cryptsy/api2/currencies.rb
22
+ - lib/cryptsy/api2/markets.rb
23
+ - lib/cryptsy/api2/order.rb
24
+ - lib/cryptsy/api2/trigger.rb
25
+ - lib/cryptsy/api2/user.rb
26
+ homepage: https://github.com/tinnvec/cryptsy-api2
27
+ licenses:
28
+ - ISC
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.4.3
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Cryptsy API v2
50
+ test_files: []