Code Example
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
apiUrl := "https://data.infoway.io/stock/batch_kline/1/10/002594.SZ%2C00285.HK%2CTSLA.US"
// Create an HTTP client
client := &http.Client{}
// Build a GET request
req, err := http.NewRequest("GET", apiUrl, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Set request headers
req.Header.Set("User-Agent", "Mozilla/5.0")
req.Header.Set("Accept", "application/json")
req.Header.Set("apiKey", "yourApikey")
// Send the request
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
// Read the response content
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
// Print the result
fmt.Printf("HTTP code:", resp.StatusCode)
fmt.Printf("message:", string(body))
}Last updated
