Post
Topic
Board Service Announcements (Altcoins)
Re: YoBit.Net - CRYPTOCURRENCY EXCHANGE & MultiCoin DICE - Free Coins every 1-24 hrs
by
deeproast
on 28/10/2015, 08:01:43 UTC
There seems to be no way to get a JSON of all currency pairs.  Even though v3 supposedly supports it It seems limited to maybe 20-30 or so pairs before it crashes and spits back an error.

There is also no single way to do this. You instead have to query the server first to see what current pairs exist.  Then you can build a "valid" url to grab the JSON.

Excuse my code but a quick example I often use for exchanges like this:

#!/usr/bin/perl -w
use JSON;
use Data::Dumper;
use LWP::UserAgent;

$ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 });
$ua->agent("$0/0.1 " . $ua->agent);

#  Get the info JSON to get up-to-date pairs
my $url = "https://yobit.net/api/3/info";
my $content = $ua->get($url);
$content = $content->content;
my $decoded_json = decode_json($content);

my $address = "https://yobit.net/api/3/ticker/";

foreach my $key (keys %{$decoded_json->{pairs}}) {
        $address .= "$key-";
}

$address .= "?ignore_invalid=1";
print "$address";

You can see the full URL as of right now here:
http://pastebin.com/AJ9wEBNt