localbitcoin api instructions
Making requests to the API Most API requests need to be encoded with application/x-www-form-urlen +coded and sent as HTTP GET or POST requests to the appropriate API en +dpoint. When uploading files multipart/form-data encoding is also sup +ported. A total of three HTTP header fields are needed: Apiauth-Key HMAC authentication key that you got when you created your + HMAC authentication from the Apps dashboard. Apiauth-Nonce A unique number given with each API request. It's value +needs to be greater with each API request. Apiauth-Signature Your API request signed with your HMAC secret that y +ou got when you create your HMAC authentication from the Apps dashboa +rd. Apiauth-Nonce Each request also requires a nonce. A nonce is an integer number, that + needs to increase with every API request. It's value has to always b +e greater than the previous request. It is used to ensure identical A +PI requests have different signatures, making impossible for someone +to copy your API requests and re-execute them later on. A good trick to creating the nonce is to use the unix timestamp in mil +liseconds. This way you'll always get an incrementing number, just be + careful to not send two API calls at the same time or they will have + the same Nonce. Most API requests need to be encoded as application/x-www-form-urlenco +ded, when uploading files multipart/form-data encoding is also suppor +ted. With most programming languages you can urlencode your API reque +sts using standard functions. With Python you can use urllib.urlencode. Example: urllib.urlencode({" +foo":"bar", "baz": "quux"} which results in ?foo=bar&baz=quux. Apiauth-Signature The Apiauth-Signature is made by creating a string containing the foll +owing arguments and then hashing them with your HMAC authentication s +ecret using SHA256. The Nonce. A 63 bit positive integer, for example unix timestamp as mi +lliseconds. HMAC authentication key. API endpoint, for example, /api/wallet/. API arguments encoded as application/x-www-form-urlencoded. Files enco +ded as multipart/form-data.
am trying to run localbitcoin api, but just getting failure: 400
#!/usr/bin/perl -w BEGIN { print "Content-type: text/plain\n\n"; } use lib '.'; use HTTP::Tinyish; use Time::HiRes qw(time); my $url = "https://localbitcoins.com/api/merchant/new_invoice/"; my $headers = { Apiauth-Key => 'sdfsdf', Apiauth-Nonce => 'sdfsdf', Apiauth-Signature => 'sdfsdf', 'Content-Type' => 'application/x-www-form-urlencoded' }; my $content = ( currency => 'USD', amount => '500', description => 'hey', internal => '0', ); my $http = HTTP::Tinyish->new(); my $response = $http->post( $url => { content => $content, headers => $headers, }); if ($response->{success}) { my $output = $response->{content}; print "$output\n"; } else { print "failure: $response->{status}\n"; }
In reply to failure: 400 by bigup401
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |