Viatext inputquery financial-related data (stocks, sectors, indices, etc.); the API returns content in JSON format.
Usage
-
First check whether the environment variable
EASTMONEY_APIKEYexists:echo $EASTMONEY_APIKEYIf it does not exist, prompt the user on the Eastmoney Skills page (https://marketing.dfcfs.com/views/finskillshub/indexuNdYscEA?appfenxiang=1)获取apikey并设置到环境变量。
⚠️ Security Considerations
- External Requests: This Skill will send your query text to the official Eastmoney API domain (
mkapi2.dfcfs.com) to obtain financial data. - Credential Protection: The API Key is used only through the environment variable
EASTMONEY_APIKEYon the server side or in a trusted runtime environment, and will not be exposed in plaintext on the frontend.
- External Requests: This Skill will send your query text to the official Eastmoney API domain (
- Use a POST request to call the API:
curl -X POST --location 'https://mkapi2.dfcfs.com/finskillshub/api/claw/query' \ --header 'Content-Type: application/json' \ --header "apikey: $EASTMONEY_APIKEY" \ --data '{"toolQuery":"用户的查询内容"}'
Applicable Scenarios
Use this skill when the user queries the following types of content:
- Market data: real-time quotes, main force capital flows, valuations, and other data for stocks, industries, sectors, indices, funds, and bonds
- Financial data: basic information, financial indicators, executive information, main business, shareholder structure, financing status, and other data for listed and non-listed companies
- Relationship and operational data: association relationship data among stocks, non-listed companies, shareholders, and executives, as well as business operation-related data
Data Limitation Notes
Please query data with a large data range with caution, such as the daily latest price of a certain stock over 3 years, as this may cause the returned content to be excessive and lead to model context explosion issues.
Return Structure Description
First-level core paths:data
| Field Path | Type | Core Meaning |
|---|---|---|
data.questionId |
String | Unique identifier ID of the data query request, associated with a single query task |
data.dataTableDTOList |
Array | [Core] List of standardized securities indicator data; each element corresponds to1 security + 1 indicatorcomplete data |
data.rawDataTableDTOList |
Array | List of raw, unprocessed securities indicator data, with a structure exactly identical to the standardized list, for raw data retrieval |
data.condition |
Object | Query conditions for this data query, recording query keywords, time range, etc. |
data.entityTagDTOList |
Array | Associated with this querysecurities entity summary information, showing the basic attributes of all involved securities after deduplication |
Second-level core paths:data.dataTableDTOList[](single indicator object, core of the table)
Each object in the array isan independent indicator data unit, containingsecurities information + table data + indicator metadata + securities tagsFour major parts.
2.1 Basic securities information
| Field path | Type | Core definition |
|---|---|---|
dataTableDTOList[].code |
String | Full securities code (including market identifier, e.g. 300059.SZ) |
dataTableDTOList[].entityName |
String | Full securities name (including code, e.g. 东方财富 (300059.SZ)) |
dataTableDTOList[].title |
String | Title of this indicator data, summarizing the query result (e.g. 东方财富 latest price) |
2.2 Table data core (for rendering)
| Field path | Type | Core definition | Table logic |
|---|---|---|---|
dataTableDTOList[].table |
Object | [Core] Standardized table data,key = indicator code, value = array of indicator values;headNameare time/dimension column values |
Keys areindicator columns,headNamearetime columns, values are the cross-cellindicator values |
dataTableDTOList[].rawTable |
Object | Raw table data, consistent withtablestructure, without data standardization |
Same astable, raw values, no format/unit correction |
dataTableDTOList[].nameMap |
Object | [Core] Column name mapping, convertingindicator codes/built-in fieldsintobusiness Chinese names(e.g. f2→latest price) | Solves the table column name "code to Chinese" issue,headNameSubis the fixed name of the time column |
dataTableDTOList[].indicatorOrder |
Array | Display order of indicator columns, elements are indicator codes (e.g. [f2]) | Controls the order of multiple indicator columns in the table, a single-element array for a single indicator |
2.3 Indicator metadata (attributes/rules)
| Field path | Type | Core definition |
|---|---|---|
dataTableDTOList[].dataType |
String | Data source type (e.g. market data/data browser) |
dataTableDTOList[].dataTypeEnum |
String | Data type enum value (HQ = market data, DATA_BROWSER = data browser) |
dataTableDTOList[].field |
Object | [Core] Detailed metadata of the current indicator, including indicator code, name, query time, granularity, etc. |
2.4 Securities tag information (entity attributes)
| Field path | Type | Core definition |
|---|---|---|
dataTableDTOList[].entityTagDTO |
Object | Detailed entity attributes of the securities associated with this indicator (e.g. securities type, market, short name, etc.) |
Three-level core paths
3.1 Indicator metadata:dataTableDTOList[].field
| Field path | Type | Core definition |
|---|---|---|
field.returnCode |
String | Unique indicator code |
field.returnName |
String | Indicator business Chinese name (e.g. latest price/closing price) |
field.startDate/endDate |
String | Time range of this query (start/end) |
field.dateGranularity |
String | Data granularity (DAY = daily, MIN = minute, etc.) |
3.2 Securities entity attributes:dataTableDTOList[].entityTagDTO
| Field path | Type | Core description |
|---|---|---|
entityTagDTO.secuCode |
String | Pure security code (without market identifier, e.g. 300059) |
entityTagDTO.marketChar |
String | Market identifier (.SZ = Shenzhen Stock Exchange, .SH = Shanghai Stock Exchange) |
entityTagDTO.entityTypeName |
String | Security type (e.g. A-share / Hong Kong stock / bond) |
entityTagDTO.fullName |
String | Full Chinese name of the security (e.g. East Money) |
Example
import os
import requests
api_key = os.getenv("EASTMONEY_APIKEY")
if not api_key:
raise ValueError("请先设置EASTMONEY_APIKEY环境变量")
url = "https://mkapi2.dfcfs.com/finskillshub/api/claw/query"
headers = {
"Content-Type": "application/json",
"apikey": api_key
}
data = {
"toolQuery": "东方财富最新价"
}
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(result)
Exception handling
- If the data result is empty, prompt the user to query East Money Miaoxiang AI
- If the request fails, check whether the API Key is correct and whether the network is normal