ViaText inputQuery financial-related data (stocks, sectors, indices, etc.); the interface returns content in JSON format.
How to Use
-
First check whether the environment variable
EASTMONEY_APIKEYexists:echo $EASTMONEY_APIKEYIf it does not exist, prompt the user on the East Money 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 East Money official API domain (
mkapi2.dfcfs.com) to retrieve 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 front end.
- External requests: This Skill will send your query text to the East Money official API domain (
- Use a POST request to call the interface:
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 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 unlisted companies
- Relationship and operations data: affiliation relationship data among stocks, unlisted companies, shareholders, and executives, as well as company operations-related data
Data Limitations
Please query large-scope data 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.
Return Structure Description
Primary 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 corresponding to1 security + 1 indicatorcomplete data |
data.rawDataTableDTOList |
Array | List of raw unprocessed securities indicator data, with exactly the same structure as 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 | Securities associated with this querySecurities entity summary information, showing the basic attributes of all involved securities after deduplication |
Secondary core paths:data.dataTableDTOList[](single-indicator object, table core)
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 description |
|---|---|---|
dataTableDTOList[].code |
String | Full securities code (including market identifier, e.g. 300059.SZ) |
dataTableDTOList[].entityName |
String | Full securities name (including code, e.g. East Money (300059.SZ)) |
dataTableDTOList[].title |
String | The title of this indicator data, summarizing the query result (e.g. East Money latest price) |
2.2 Table data core (for rendering)
| Field path | Type | Core description | Table logic |
|---|---|---|---|
dataTableDTOList[].table |
Object | [Core] Standardized table data,key = indicator code, value = indicator value array;headNameis the time/dimension column value |
The key isindicator column,headNameistime column, the value is the intersecting cell'sindicator value |
dataTableDTOList[].rawTable |
Object | Raw table data, consistent withtablestructure, without data standardization processing |
Same astable, for raw values, no format/unit correction |
dataTableDTOList[].nameMap |
Object | [Core] Column name mapping relationship, convertingindicator code/built-in fieldtobusiness Chinese name(e.g. f2→latest price) | Solves the problem of table column names "code to Chinese",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; for a single indicator it is a single-element array |
2.3 Indicator metadata (attributes/rules)
| Field path | Type | Core description |
|---|---|---|
dataTableDTOList[].dataType |
String | Data source type (e.g. market data/data browser) |
dataTableDTOList[].dataTypeEnum |
String | Data type enumeration 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 (subject attributes)
| Field path | Type | Core description |
|---|---|---|
dataTableDTOList[].entityTagDTO |
Object | Detailed subject attributes of the security associated with this indicator (e.g. security type, market, short name, etc.) |
Three-level core paths
3.1 Indicator metadata:dataTableDTOList[].field
| Field path | Type | Core description |
|---|---|---|
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 subject attributes:dataTableDTOList[].entityTagDTO
| Field path | Type | Core definition |
|---|---|---|
entityTagDTO.secuCode |
String | Stock pure 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 via East Money Miaoxiang AI
- If the request fails, check whether the API Key is correct and whether the network is normal