Hi all
Did anyone have any piece of code working with binance API?
I found myself in need of an "hello word" example and I did not find it on the intenet.
Anyone can help me to understand that I am thinking correct or not please.
I have the following code
Code:
procedure TfrmMain.btnInfoClick(Sender: TObject);
var workStream : TStringStream;
workResponse : TStringStream;
responseObject : ISuperObject;
serverTIME : Int64;
begin
mDEBUG.Lines.Clear;
try
workStream := TStringStream.Create;
workResponse := TStringStream.Create;
restCLIENT_MAIN.ResetToDefaults;
restREQUEST_MAIN.ResetToDefaults;
restRESPONSE_MAIN.ResetToDefaults;
restCLIENT_MAIN.BaseURL := API_URL;
serverTIME := GetAPI_TIME;
restREQUEST_MAIN.Resource := '/sapi/v1/broker/info';
restREQUEST_MAIN.ResourceSuffix := '?timestamp=' + serverTIME.ToString + '&signature=' + SECRET_KEY;
restREQUEST_MAIN.Method := TRESTRequestMethod.rmGET;
restREQUEST_MAIN.AddParameter('Content-Type', 'application/json');
restREQUEST_MAIN.AddParameter('X-MBX-APIKEY', CLIENT_KEY);
restREQUEST_MAIN.Execute;
workResponse := TStringStream.Create(restRESPONSE_MAIN.JSONText);
responseObject := TSuperObject.ParseStream(workResponse, True);
if responseObject <> nil then begin
mDEBUG.Lines.Add(responseObject.AsString);
end else begin
mDEBUG.Lines.Add(restRESPONSE_MAIN.Content);
end;
finally
mDEBUG.Lines.Add('');
mDEBUG.Lines.Add('restCLIENT_MAIN.BaseURL:' + restCLIENT_MAIN.BaseURL);
mDEBUG.Lines.Add('restREQUEST_MAIN.Resource:' + restREQUEST_MAIN.Resource);
mDEBUG.Lines.Add('restREQUEST_MAIN.ResourceSuffix:' + restREQUEST_MAIN.ResourceSuffix);
FreeAndNil(workStream);
FreeAndNil(workResponse);
end;
end;
the result is
Code:
{"msg":"API-key format invalid.","code":-2014}
but the postman give me a different error. (timestamp difference)
What I am missing?
Anyone can help me with some hints?