> ## Documentation Index
> Fetch the complete documentation index at: https://alltick.co/apis/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API Request Example

> Go, Java, PHP, and Python request examples for the AllTick REST API.

REST API uses the `X-API-Key` request header for authentication. The following examples call the single-product K-line endpoint; replace `YOUR_API_KEY` with your actual API key.

```go Go theme={null}
package main
import (
  "fmt"
  "io"
  "net/http"
  "net/url"
)
func main() {
  queryData := `{"trace":"test-001","data":{"code":"700.HK","kline_type":1,"kline_timestamp_end":0,"query_kline_num":2,"adjust_type":0}}`
  endpoint := "https://quote.alltick.co/quote-stock-b-api/v1/kline/" + url.PathEscape(queryData)
  req, _ := http.NewRequest(http.MethodGet, endpoint, nil)
  req.Header.Set("X-API-Key", "YOUR_API_KEY")
  resp, err := http.DefaultClient.Do(req); if err != nil { panic(err) }; defer resp.Body.Close()
  body, _ := io.ReadAll(resp.Body); fmt.Println(resp.StatusCode, string(body))
}
```

```java Java theme={null}
import java.net.URI;
import java.net.http.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
class RestApiExample {
  public static void main(String[] args) throws Exception {
    String query = "{\"trace\":\"test-001\",\"data\":{\"code\":\"700.HK\",\"kline_type\":1,\"kline_timestamp_end\":0,\"query_kline_num\":2,\"adjust_type\":0}}";
    String endpoint = "https://quote.alltick.co/quote-stock-b-api/v1/kline/" + URLEncoder.encode(query, StandardCharsets.UTF_8);
    HttpRequest request = HttpRequest.newBuilder(URI.create(endpoint)).header("X-API-Key", "YOUR_API_KEY").GET().build();
    HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.statusCode()); System.out.println(response.body());
  }
}
```

```php PHP theme={null}
<?php
$queryData = json_encode(["trace" => "test-001", "data" => ["code" => "700.HK", "kline_type" => 1, "kline_timestamp_end" => 0, "query_kline_num" => 2, "adjust_type" => 0]]);
$ch = curl_init("https://quote.alltick.co/quote-stock-b-api/v1/kline/" . rawurlencode($queryData));
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: YOUR_API_KEY"]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$body = curl_exec($ch); echo curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL . $body; curl_close($ch);
?>
```

```python Python theme={null}
import json
import requests
from urllib.parse import quote
query_data = {"trace": "test-001", "data": {"code": "700.HK", "kline_type": 1, "kline_timestamp_end": 0, "query_kline_num": 2, "adjust_type": 0}}
url = "https://quote.alltick.co/quote-stock-b-api/v1/kline/" + quote(json.dumps(query_data, separators=(",", ":")))
response = requests.get(url, headers={"X-API-Key": "YOUR_API_KEY"})
print(response.status_code); print(response.json())
```

## Batch K-line POST request

```bash theme={null}
curl --request POST \
  --url https://quote.alltick.co/quote-stock-b-api/v1/batch-kline \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: YOUR_API_KEY' \
  --data '{"trace":"test-001","data":{"symbol_list":[{"code":"700.HK","kline_type":1,"kline_timestamp_end":0,"query_kline_num":1,"adjust_type":0}]}}'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.