Using binance api to track crypto prices

Hello.
I'm fairly new on arduino world and trying to create projects.
I'm trying to make a ethereum price display. Got arduino uno, esp8266 module and an lcd display.
I can connect esp8266 to wifi but can't get http. https://api.binance.com/api/v1/ticker/price?symbol=ETHBUSD trying to extract this website, it was looking very easy at the start but couldn't handle it.
Can anyone help me

@mustafaokeer, your topic was moved to a more suitable location of the forum.

1 Like

Sure - supply ALL the information we need to help. HINT : Code, what Arduino you have, how is it connected to the internet etc

I have arduino uno (clone), esp8266 module (i guess it's also clone) and an lcd screen (don't know the model)
I've tried this code lately. It works until loop, and connects to internet via wifi router. But can't connect to website and says connection failed.
I just want to pull those texts on https://api.binance.com/api/v1/ticker/price?symbol=ETHBUSD and project on lcd screen.

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

#include <SoftwareSerial.h>



int    HTTP_PORT   = "";
String HTTP_METHOD = "GET"; 
char   HOST_NAME[] = "api.binance.com"; // hostname of web server:
String PATH_NAME   = "/api/v1/ticker/price?symbol=ETHBUSD";

String agAdi = "Xiaomi";                 //A─č─▒m─▒z─▒n ad─▒n─▒ buraya yaz─▒yoruz.    
String agSifresi = "5327608856A!";           //A─č─▒m─▒z─▒n ┼čifresini buraya yaz─▒yoruz.
int rxPin = 10;                                               //ESP8266 RX pini
int txPin = 11;                                               //ESP8266 TX pini
WiFiClient client;

SoftwareSerial esp(rxPin, txPin);                             //Seri haberle┼čme pin ayarlar─▒n─▒ yap─▒yoruz.
void setup() {  

  
  Serial.begin(9600);  //Seri port ile haberle┼čmemizi ba┼člat─▒yoruz.
  Serial.println("Started");
  esp.begin(115200);                                          //ESP8266 ile seri haberle┼čmeyi ba┼člat─▒yoruz.
  esp.println("AT");                                          //AT komutu ile mod├╝l kontrol├╝n├╝ yap─▒yoruz.
  Serial.println("AT Yolland─▒");
  while(!esp.find("OK")){                                     //Mod├╝l haz─▒r olana kadar bekliyoruz.
    esp.println("AT");
    Serial.println("ESP8266 Bulunamad─▒.");
  }
  Serial.println("OK Komutu Al─▒nd─▒");
  esp.println("AT+CWMODE=1");                                 //ESP8266 mod├╝l├╝n├╝ client olarak ayarl─▒yoruz.
  while(!esp.find("OK")){                                     //Ayar yap─▒lana kadar bekliyoruz.
    esp.println("AT+CWMODE=1");
    Serial.println("Ayar Yap─▒l─▒yor....");
  }
  Serial.println("Client olarak ayarland─▒");
  Serial.println("Aga Baglaniliyor...");
  esp.println("AT+CWJAP=\""+agAdi+"\",\""+agSifresi+"\"");    //A─č─▒m─▒za ba─član─▒yoruz.
  while(!esp.find("OK"));                                     //A─ča ba─članana kadar bekliyoruz.
  Serial.println("Aga Baglandi.");
  delay(1000);

}
void loop() {
 if(client.connect(HOST_NAME, HTTP_PORT)) {
  Serial.println("Connected to server");
} else {
  Serial.println("connection failed");
}
  client.println(HTTP_METHOD + " " + PATH_NAME + " HTTP/1.1");
  client.println("Host: " + String(HOST_NAME));
  client.println("Connection: close");
  client.println(); // end HTTP request header
}

Can you hit the site with your ESP? Is the problem parsing what it sends you?

no, i cant reach site i guess.
it returns as "connection failed" after this "if(client.connect(HOST_NAME, HTTP_PORT))"
also i'm not sure should i provide a port, tried port 80 but no luck.

I think the WiFi library is expecting a WiFi Shield and not a ESP8266 connected via serial. I think you have to look up how to send AT commands to the ESP8266 to connect to a web server and send a GET request.

1 Like

you are requesting from a https server while expexting a http website. You're gonna need to switch to insecure client mode (include the wifiClientSecure library and use client.setInsecure() ). You could also try to figure out how to set up a secure client properly, but i have not been able to do that.
addition: take care with sending personal information via an unsecured connection! :wink:

thanks for all help. i gave up.
I think arduino isn't for me :sweat_smile: