Skip to main content
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

func http_example() {

	/*
		URL-encode the following JSON and copy it into the query field of the HTTP query string
		{"trace" : "go_http_test1","data" : {"code" : "700.HK","kline_type" : 1,"kline_timestamp_end" : 0,"query_kline_num" : 2,"adjust_type": 0}}

		Special Note:
		github: https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
		Token Application: https://alltick.co
		Replace testtoken in the URL below with your own token
		API address for forex, cryptocurrencies, and precious metals:
		https://quote.alltick.co/quote-b-api
		Stock API address:
		https://quote.alltick.co/quote-stock-b-api
	*/
	url := "https://quote.alltick.co/quote-stock-b-api/kline"
	log.Println("Request URL:", url)

	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}

	q := req.URL.Query()
	token := "testtoken"
	q.Add("token", token)
	queryStr := `{"trace":"1111111111111111111111111","data":{"code":"AAPL.US","kline_type":1,"kline_timestamp_end":0,"query_kline_num":10,"adjust_type":0}}`
	q.Add("query", queryStr)
	req.URL.RawQuery = q.Encode()
	// Send request
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		fmt.Println("Error sending request:", err)
		return
	}
	defer resp.Body.Close()

	body2, err := ioutil.ReadAll(resp.Body)

	if err != nil {

		log.Println("Failed to read response:", err)

		return

	}

	log.Println("Response content:", string(body2))

}

AllTick Website

Official website: https://alltick.co/