POSTaliyunmarket-cmapi00066016-finance-us-shares-price
米国株価
米国株価
導入ドキュメント
米国株価
実装サンプルコード
Shell、Python、Go、Java、PHP の呼び出し例をまとめ、既存プロジェクトに組み込みやすくしています。
Shell 例
curl --request POST \
--url 'https://openapi.toolkk.com/v1/aliyunmarket-cmapi00066016-finance-us-shares-price' \
--header 'Content-Type: application/json' \
--header 'X-API-Key: YOUR_API_KEY' \
--data '{\n "symbol": "品种代码,以英文逗号分割,如:INTC,AAPL"\n}'Python 例
import os
import requests
url = "https://openapi.toolkk.com/v1/aliyunmarket-cmapi00066016-finance-us-shares-price"
payload = {
"symbol": "品种代码,以英文逗号分割,如:INTC,AAPL"
}
headers = {
"Content-Type": "application/json",
"X-API-Key": os.getenv("TOOLKK_API_KEY", "YOUR_API_KEY"),
}
response = requests.request("POST", url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
print(response.json())Go 例
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
endpoint := "https://openapi.toolkk.com/v1/aliyunmarket-cmapi00066016-finance-us-shares-price"
payload := []byte("{\n \"symbol\": \"品种代码,以英文逗号分割,如:INTC,AAPL\"\n}")
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
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, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}Java 例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class ToolkkExample {
public static void main(String[] args) throws Exception {
String payload = "{\n \"symbol\": \"品种代码,以英文逗号分割,如:INTC,AAPL\"\n}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://openapi.toolkk.com/v1/aliyunmarket-cmapi00066016-finance-us-shares-price"))
.method("POST", HttpRequest.BodyPublishers.ofString(payload))
.header("Content-Type", "application/json")
.header("X-API-Key", "YOUR_API_KEY")
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}PHP 例
<?php
$endpoint = 'https://openapi.toolkk.com/v1/aliyunmarket-cmapi00066016-finance-us-shares-price';
$payload = "{\n \"symbol\": \"品种代码,以英文逗号分割,如:INTC,AAPL\"\n}";
$ch = curl_init($endpoint);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: YOUR_API_KEY',
],
CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
if ($response === false) {
throw new RuntimeException(curl_error($ch));
}
curl_close($ch);
echo $response;リクエスト例
{
"symbol": "品种代码,以英文逗号分割,如:INTC,AAPL"
}レスポンス例
{
"msg": "成功",
"code": 200,
"taskNo": "200966658220607506216602",
"data": {
"AAPL": {
"after_price": "221.0800",
"volume_avg10": "86695457",
"market_value": "3397265867100",
"trade_time": "2024-07-04 01:00:00",
"change": "1.2800",
"eps": "6.46",
"after_volume": "1132411",
"volume": "37369801",
"shares": "15334082000",
"after_change": "-0.47",
"high": "221.5500",
"update_time": "2024-07-04 09:45:24",
"low": "219.0300",
"pe": "34.300000",
"price": "221.5500",
"name": "苹果",
"dividend": "0.25",
"52week_low": "163.8300",
"after_changeRate": "-0.21",
"changeRate": "0.58",
"preclose": "220.2700",
"open": "220.0000",
"52week_high": "221.5500",
"after_time": "2024-07-04 05:00:00"
}
}
}リクエスト項目
以下の項目はサンプル JSON から自動抽出した参考情報です。
| パス | 型 | サンプル値 |
|---|---|---|
| type | string | object |
| properties | object | {...} |
| properties.symbol | object | {...} |
| properties.symbol.type | string | string |
| properties.symbol.description | string | 品种代码,以英文逗号分割,如:INTC,AAPL |
| required | array | "symbol" |
| required[] | string | symbol |
レスポンス項目
以下の項目はサンプル JSON から自動抽出した参考情報です。
| パス | 型 | サンプル値 |
|---|---|---|
| type | string | object |
| properties | object | {...} |
| properties.msg | object | {...} |
| properties.msg.type | string | string |
| properties.msg.example | string | 成功 |
| properties.msg.description | string | 返回码对应描述 |
| properties.code | object | {...} |