import requests
api_url = "https://data.infoway.io/stock/v2/batch_kline"
headers = {
"User-Agent": "Mozilla/5.0",
"Accept": "application/json",
"Content-Type": "application/json",
"apiKey": "yourApikey",
}
payload = {
"klineType": 1,
"klineNum": 1,
"codes": "SPLS.US"
}
response = requests.post(api_url, headers=headers, json=payload)
print(f"HTTP code: {response.status_code}")
print(f"message: {response.text}")
import requests
api_url = "https://data.infoway.io/stock/v2/batch_kline"
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"apiKey": "yourApikey",
}
payload = {
"klineType": 1,
"klineNum": 10,
"codes": "SPLS.US",
}
response = requests.post(api_url, headers=headers, json=payload)
print(f"HTTP code: {response.status_code}")
print(f"message: {response.text}")
const apiUrl = "https://data.infoway.io/stock/v2/batch_kline";
const payload = {
klineType: 1,
klineNum: 10,
codes: "SPLS.US",
};
fetch(apiUrl, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
apiKey: "yourApikey",
},
body: JSON.stringify(payload),
})
.then(async (res) => {
console.log("HTTP code:", res.status);
console.log("message:", await res.text());
})
.catch(console.error);
package org.example.http;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class HttpExample {
public static void main(String[] args) {
try {
String apiUrl = "https://data.infoway.io/stock/v2/batch_kline";
String payload = "{\"klineType\":1,\"klineNum\":10,\"codes\":\"SPLS.US\"}";
URL url = new URL(apiUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("apiKey", "yourApikey");
try (OutputStream os = connection.getOutputStream()) {
byte[] input = payload.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
int responseCode = connection.getResponseCode();
System.out.println("HTTP code: " + responseCode);
BufferedReader reader;
if (responseCode == HttpURLConnection.HTTP_OK) {
reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} else {
reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
}
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
System.out.println("message: " + response);
} catch (IOException e) {
e.printStackTrace();
}
}
}
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
apiUrl := "https://data.infoway.io/stock/v2/batch_kline"
payload := strings.NewReader("{\"klineType\":1,\"klineNum\":10,\"codes\":\"SPLS.US\"}")
client := &http.Client{}
req, err := http.NewRequest("POST", apiUrl, payload)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("User-Agent", "Mozilla/5.0")
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("apiKey", "yourApikey")
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println("HTTP code:", resp.StatusCode)
fmt.Println("message:", string(body))
}
<?php
$apiUrl = 'https://data.infoway.io/stock/v2/batch_kline';
$payload = json_encode([
'klineType' => 1,
'klineNum' => 10,
'codes' => 'SPLS.US',
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'User-Agent: Mozilla/5.0',
'Accept: application/json',
'Content-Type: application/json',
'apiKey: yourApikey'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP code: $httpCode\n";
echo "message: $response";
curl -X POST "https://data.infoway.io/stock/v2/batch_kline" \
-H "apiKey: YOUR_API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"klineType":1,"klineNum":10,"codes":"SPLS.US"}'
import json
import websocket
def on_open(ws):
ws.send(json.dumps({
"action": "subscribe",
"symbols": ["SPLS.US"]
}))
ws = websocket.WebSocketApp(
"wss://data.infoway.io/ws",
header=["Authorization: Bearer YOUR_API_KEY"],
on_open=on_open,
on_message=lambda ws, msg: print(msg),
)
ws.run_forever()