Autor Beitrag
spoof
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Mo 25.11.13 21:03 
Hey, ich würde gerne folgende API benutzen:
www.cryptsy.com/pages/api
hab aber noch nie mit API´s gearbeitet und finde nur Tutorials von 2003-2004.

Kann mir jemand kurz erklären wie man eine API benutzt?
Ich möchte folgende Kursstatistik in mein Programm einbauen sowie die darunter stehenden kauf und verkauf Preise:
www.cryptsy.com/markets/view/45


Moderiert von user profile iconMartok: Topic aus Sonstiges (Delphi) verschoben am Mo 25.11.2013 um 22:39
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mo 25.11.13 23:38 
Hi!

Was genau ist jetzt das Problem? Dort verlinkt hast du die vollständige Dokumentation der API, mitsamt einem Codebeispiel für PHP (Was genau dort steht kann ich leider nicht mehr sehen, weil mich die Seite geblockt hat(!?) und nicht für sowas Cookies freigebe).

Was hast du, was funktioniert (nicht)?

Viele Grüße,
Martok

PS: verschoben nach "Internet/Netzwerk".

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
OlafSt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 486
Erhaltene Danke: 99

Win7, Win81, Win10
Tokyo, VS2017
BeitragVerfasst: Di 26.11.13 12:50 
Dem guten Mann ist nicht klar, das er schon die ganze Zeit eine API benutzt: das WinAPI ;)

Eine API ist nix anderes als eine Routinensammlung zu einem bestimmten Zweck. Um Kartenleser anzusteuern und die Smartcards auszulesen, braucht man Routinen - zusammengefaßt als CT-API oder PC/SC-API. Nix anderes ist die gezeigte API.

Du kennst also die Namen der Routinen, die Parameter, die sie so brauchen (Input) und das, was sie zurückgeben (Output). Mehr gibt es tatsächlich nicht darüber zu wissen. Ergo: Go for it !

_________________
Lies, was da steht. Denk dann drüber nach. Dann erst fragen.
bole
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 107
Erhaltene Danke: 15

win 10

BeitragVerfasst: Di 26.11.13 23:04 
Hallo spoof

Ich nehme an das Die die bisherigen Antworten wohl nicht wirklich was genutzt haben...

Schau mal diesen Thread an www.entwickler-ecke....amp;highlight=wetter Da hat user profile iconMathematiker was ähnliches mit Wetterdaten gemacht. Diese API gibt die Daten auch im JSON Format zurück.

Wie man diese Daten dann aber korrekt Interpretiert und Anzeigt steht auf einem anderen Blatt...


Viel Glück :wink:

Bole

_________________
ein programm macht nicht das was du willst sondern was du schreibst!
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 28.11.13 13:13 
Hi,

ich habe dir mal den Teil aus meinem BitCoin-Programm rausgesucht, wo der JSON-String geparst wird. (Also die TokenList durchgehen...)
Ich fülle damit meine Klassen (TMarket), aber das kannst du analog in deine Struktur übernehmen...
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
procedure TTraderMarket.ParserToMarkets(AParser: TJSONParser; AMarkets: TMarkets);
var
  i: Integer;
  LKind: TJSONTokenKind;
  LString, LStr2: String;
  LState: TParsingState;
  LMarket: TMarket;
  LTrade: TTradeItem;
  LOrder: TOrderItem;
  LOldDecimalSep: Char;
begin
  for LMarket in FMarkets do
    LMarket.Clear;
  FMarkets.Clear;
  LOldDecimalSep := FormatSettings.DecimalSeparator;
  try
    FormatSettings.DecimalSeparator := '.';
    LState := psNone;
    for i := 0 to AParser.TokenList.Count -1 do
    begin
      LKind := AParser.TokenList.GetItemKind(i);
      LString := AParser.TokenList.GetItemContent(i);

      if LString = '"marketid"' then
      begin
        LMarket := TMarket.Create;
        LMarket.NodeId := AParser.TokenList.GetItemContent(i-2);
        LMarket.MarketId := AParser.TokenList.GetItemContent(i+1);
        LMarket.Labl := AParser.TokenList.GetItemContent(i+4);
        LMarket.LastTradePrice := StrToFloat(AParser.TokenList.GetItemContent(i+7));
        LMarket.Volume := StrToFloat(AParser.TokenList.GetItemContent(i+10));
        LMarket.LastTradeTime := CryptsyDateStringToDateTime(AParser.TokenList.GetItemContent(i+13));
        LMarket.PrimaryName := AParser.TokenList.GetItemContent(i+16);
        LMarket.PrimaryCode := AParser.TokenList.GetItemContent(i+19);
        LMarket.SecondaryName := AParser.TokenList.GetItemContent(i+22);
        LMarket.SecondaryCode := AParser.TokenList.GetItemContent(i+25);
      end;

      if (LKind = jsArrayStart) and (AParser.TokenList.GetItemContent(i-1) = '"recenttrades"'then
      begin
        LState := psRecentTrades;
      end
      else
      if (LKind = jsArrayStart) and (AParser.TokenList.GetItemContent(i-1) = '"sellorders"'then
      begin
        LState := psSellOrders;
      end
      else
      if (LKind = jsArrayStart) and (AParser.TokenList.GetItemContent(i-1) = '"buyorders"'then
      begin
        LState := psBuyOrders;
      end;

      case LState of
        psNone:
          begin
            Continue;
          end;
        psRecentTrades:
          begin
            if (LString = '"id"'and
               (AParser.TokenList.GetItemContent(i+3) = '"time"'and
               (AParser.TokenList.GetItemContent(i+6) = '"price"'and
               (AParser.TokenList.GetItemContent(i+9) = '"quantity"'and
               (AParser.TokenList.GetItemContent(i+12) = '"total"'then
            begin
              LTrade := TTradeItem.Create;
              LTrade.Id := AParser.TokenList.GetItemContent(i+1);
              LTrade.Time := CryptsyDateStringToDateTime(AParser.TokenList.GetItemContent(i+4));
              LTrade.Price := StrToFloat(AParser.TokenList.GetItemContent(i+7));
              LTrade.Qty := StrToFloat(AParser.TokenList.GetItemContent(i+10));
              LTrade.Total := StrToFloat(AParser.TokenList.GetItemContent(i+13));
              LMarket.RecentTrades.Add(LTrade);
            end;
          end;
        psSellOrders:
          begin
            if (AParser.TokenList.GetItemContent(i+2) = '"price"'and
               (AParser.TokenList.GetItemContent(i+5) = '"quantity"'and
               (AParser.TokenList.GetItemContent(i+8) = '"total"'then
            begin
              LOrder := TOrderItem.Create;
              LOrder.Price := StrToFloat(AParser.TokenList.GetItemContent(i+3));
              LOrder.Qty := StrToFloat(AParser.TokenList.GetItemContent(i+6));
              LOrder.Total := StrToFloat(AParser.TokenList.GetItemContent(i+9));
              LMarket.SellOrders.Add(LOrder);
            end;
          end;
        psBuyOrders:
          begin
            if (AParser.TokenList.GetItemContent(i+2) = '"price"'and
               (AParser.TokenList.GetItemContent(i+5) = '"quantity"'and
               (AParser.TokenList.GetItemContent(i+8) = '"total"'then
            begin
              LOrder := TOrderItem.Create;
              LOrder.Price := StrToFloat(AParser.TokenList.GetItemContent(i+3));
              LOrder.Qty := StrToFloat(AParser.TokenList.GetItemContent(i+6));
              LOrder.Total := StrToFloat(AParser.TokenList.GetItemContent(i+9));
              LMarket.BuyOrders.Add(LOrder);
            end;
          end;
      end;

      if (LState = psBuyOrders) and (lKind = jsArrayEnd) and (LMarket <> nilthen
      begin
        LState := psNone;
        FMarkets.Add(LMarket);
      end;
    end;
  finally
    FormatSettings.DecimalSeparator := LOldDecimalSep;
  end;
end;


Die Unit "jsonparser" liegt Delphi bei.

Gruß
rd3
spoof Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Do 28.11.13 23:48 
Hallo, danke erstmal für die ganzen Antworten.
Ich hab atm leider kaum Zeit zum coden weshalb ich noch nicht richtig weiter machen konnte aber ich glaube ich weiß schon grob wie das ganze gehen soll. In den Api´s werden immer die aktuellen kurse usw gesendet, die muss ich dann wohl irgendwie einlesen so wie ich das verstanden hab. Muss mich damit genauer befassen hat so keinen Sinn atm.^^
Danke trotzdem werde den Thread vllt iwann mal ausgraben :D