Skip to content

Commit 7fdd3ab

Browse files
feat: improve component documentation and validation
- Add markdown formatting to all example values with backticks - Highlight date formats (`YYYY-MM-DD`) in prop descriptions - Add `min: 1` validation to all page props across 19 action files - Remove verbose pagination descriptions in favor of built-in validation - Standardize prop definitions using `propDefinitions` from app file - Convert comma-separated string props to `string[]` type for better UX - Remove redundant `if ($ && $.export)` checks from all actions - Remove custom `try/catch` blocks to leverage Pipedream's native error handling - Clean up `handleApiError` utility function and related imports - Fix prop descriptions to use proper options instead of text descriptions - Update README.md to be more concise and professional per feedback This refactor improves code maintainability, user experience, and follows Pipedream component best practices for validation, error handling, and documentation formatting.
1 parent 13a06c6 commit 7fdd3ab

File tree

27 files changed

+864
-966
lines changed

27 files changed

+864
-966
lines changed

components/token_metrics/README.md

Lines changed: 9 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -30,102 +30,17 @@ The API uses API key authentication via the `x-api-key` header. Your API key sho
3030
3. In Pipedream, connect the Token Metrics app using your API key
3131
4. The API key will be automatically included in all requests via the `x-api-key` header
3232

33-
# Available Actions
34-
35-
## Core Data Actions
36-
- **Get Tokens**: Retrieve comprehensive token listings with metadata and analytics
37-
- **Get Price**: Fetch current token prices for specified assets
38-
- **Get Top Market Cap Tokens**: Access tokens ranked by market capitalization
39-
40-
## Trading & Signals
41-
- **Get Trading Signals**: AI-generated long/short trading signals for all tokens
42-
- **Get Hourly Trading Signals**: Real-time hourly trading signals
43-
- **Get Moonshot Tokens**: AI-curated high-potential token picks
44-
45-
## Market Analysis
46-
- **Get Market Metrics**: Comprehensive crypto market analytics and sentiment indicators
47-
- **Get Correlation**: Token correlation analysis with top 100 market cap assets
48-
- **Get Scenario Analysis**: Price predictions based on different market scenarios
49-
- **Get Resistance Support**: Historical resistance and support levels
50-
51-
## OHLCV Data
52-
- **Get Hourly OHLCV**: Hourly Open, High, Low, Close, Volume data
53-
- **Get Daily OHLCV**: Daily OHLCV data for historical analysis
54-
55-
## Grading Systems
56-
- **Get TM Grades**: Latest Token Metrics grades with trader and quant scores
57-
- **Get TM Grades Historical**: Historical TM Grade data over time
58-
- **Get Fundamental Grades**: Fundamental analysis scores (community, exchange, VC, tokenomics)
59-
- **Get Fundamental Grades Historical**: Historical fundamental grade data
60-
- **Get Technology Grades**: Technology assessment scores (activity, security, repository)
61-
- **Get Technology Grades Historical**: Historical technology grade data
62-
63-
## Advanced Analytics
64-
- **Get AI Reports**: Comprehensive AI-generated token analysis reports
65-
- **Get Quantmetrics**: Advanced quantitative metrics and analysis
66-
- **Get Crypto Investors**: Latest crypto investor data and scores
67-
68-
## Indices & Performance
69-
- **Get Indices**: Access active and passive crypto indices
70-
- **Get Indices Holdings**: Current holdings and weightings for specific indices
71-
- **Get Indices Performance**: Historical performance data for crypto indices
33+
# Available Components
34+
35+
This component provides pre-built actions for all major Token Metrics API endpoints, covering token data, AI-powered analytics, market metrics, trading signals, grading systems, and more. All actions support filtering, pagination, and use API key authentication.
7236

7337
# Example Use Cases
7438

75-
## Automated Trading Systems
76-
```javascript
77-
// Monitor trading signals and execute automated trades
78-
const signals = await steps.token_metrics.getTradingSignals({
79-
symbol: "BTC,ETH",
80-
signal: "1" // Bullish signals only
81-
});
82-
83-
// Process signals and trigger trading actions
84-
```
85-
86-
## Portfolio Management Dashboard
87-
```javascript
88-
// Create comprehensive portfolio tracking
89-
const tokens = await steps.token_metrics.getTokens({
90-
category: "defi,layer-1",
91-
limit: 100
92-
});
93-
94-
const grades = await steps.token_metrics.getTmGrades({
95-
token_id: tokens.data.map(t => t.token_id).join(",")
96-
});
97-
98-
// Combine data for portfolio analysis
99-
```
100-
101-
## Market Research Automation
102-
```javascript
103-
// Generate detailed investment research
104-
const aiReports = await steps.token_metrics.getAiReports({
105-
symbol: "SOL,AVAX"
106-
});
107-
108-
const fundamentals = await steps.token_metrics.getFundamentalGrades({
109-
symbol: "SOL,AVAX"
110-
});
111-
112-
// Create comprehensive research reports
113-
```
114-
115-
## Risk Management System
116-
```javascript
117-
// Monitor market conditions and correlations
118-
const marketMetrics = await steps.token_metrics.getMarketMetrics({
119-
start_date: "2025-07-01",
120-
end_date: "2025-07-10"
121-
});
122-
123-
const correlations = await steps.token_metrics.getCorrelation({
124-
symbol: "BTC"
125-
});
126-
127-
// Implement risk management strategies
128-
```
39+
- **Automated Trading Systems**: Monitor AI-generated trading signals and execute automated trades
40+
- **Portfolio Management**: Track cryptocurrency portfolios with comprehensive token metrics and grades
41+
- **Market Research**: Generate detailed investment analysis using AI reports and fundamental data
42+
- **Risk Management**: Monitor market conditions, correlations, and implement risk strategies
43+
- **Price Monitoring**: Track token prices and receive alerts on significant market movements
12944

13045
# API Endpoint
13146

@@ -139,12 +54,7 @@ Please refer to the [Token Metrics API documentation](https://developers.tokenme
13954

14055
# Data Filtering & Pagination
14156

142-
Most actions support comprehensive filtering options:
143-
144-
- **Token Identification**: Filter by `token_id`, `symbol`, or `token_name`
145-
- **Market Filters**: Filter by `category`, `exchange`, `market_cap`, `volume`, `fdv`
146-
- **Date Ranges**: Use `start_date` and `end_date` for historical data
147-
- **Pagination**: Control results with `limit` (default: 50) and `page` (default: 1) parameters
57+
Actions support comprehensive filtering by token identifiers, market criteria, date ranges, and standard pagination controls. See the [Token Metrics API documentation](https://developers.tokenmetrics.com/) for specific filter options.
14858

14959
# Error Handling
15060

@@ -170,9 +80,3 @@ The component includes comprehensive error handling for common scenarios:
17080
- **Pipedream Community**: For integration and workflow assistance
17181
- **Component Issues**: Report bugs or request features via the Pipedream platform
17282
- **Email Support**: [email protected] for API-related issues
173-
174-
# Version
175-
176-
Current version: 0.0.1
177-
178-
Built with Pipedream Platform v3.0.3
Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import tokenMetrics from "../../token_metrics.app.mjs";
2-
import { ENDPOINTS, FILTER_DEFINITIONS } from "../../common/constants.mjs";
2+
import { ENDPOINTS } from "../../common/constants.mjs";
33
import { buildParams, generateFilterSummary } from "../../common/utils.mjs";
44

55
const endpoint = ENDPOINTS.AI_REPORTS;
@@ -12,14 +12,20 @@ export default {
1212
type: "action",
1313
props: {
1414
tokenMetrics,
15-
// Filter props based on endpoint configuration and API documentation
15+
// Filter props using propDefinitions from the app
1616
tokenId: {
17-
...FILTER_DEFINITIONS.token_id,
18-
description: "Comma Separated Token IDs. Click here to access the list of token IDs. Example: 37493,3484",
17+
propDefinition: [
18+
tokenMetrics,
19+
"tokenId",
20+
],
21+
description: "Select Token IDs to get AI reports for. Example: `37493,3484`",
1922
},
2023
symbol: {
21-
...FILTER_DEFINITIONS.symbol,
22-
description: "Comma Separated Token Symbols. Click here to access the list of token symbols. Example: APX,PAAL",
24+
propDefinition: [
25+
tokenMetrics,
26+
"symbol",
27+
],
28+
description: "Select token symbols to get AI reports for. Example: `APX,PAAL`",
2329
},
2430
// Pagination props
2531
limit: {
@@ -35,41 +41,26 @@ export default {
3541
tokenMetrics,
3642
"page",
3743
],
38-
description: "Enables pagination and data retrieval control by skipping a specified number of items before fetching data. Page should be a non-negative integer, with 1 indicating the beginning of the dataset. Defaults to 1",
44+
min: 1,
3945
default: 1,
4046
},
4147
},
4248
async run({ $ }) {
4349
// Build parameters using utility function
4450
const params = buildParams(this, endpoint.filters);
4551

46-
try {
47-
const response = await this.tokenMetrics.getAiReports({
48-
$,
49-
params,
50-
});
52+
const response = await this.tokenMetrics.getAiReports({
53+
$,
54+
params,
55+
});
5156

52-
// Generate summary using utility function
53-
const filterSummary = generateFilterSummary(this, endpoint.filters);
54-
55-
// Use $ context for export
56-
if ($ && $.export) {
57-
const dataLength = response.data?.length || 0;
58-
$.export("$summary", `Successfully retrieved AI reports for ${dataLength} tokens${filterSummary}`);
59-
}
60-
61-
return response;
62-
} catch (error) {
63-
// Enhanced error handling
64-
const errorMessage = error.response?.data?.message || error.message || "An error occurred";
65-
const statusCode = error.response?.status;
66-
67-
if ($ && $.export) {
68-
$.export("$summary", `Error: ${errorMessage}`);
69-
}
70-
71-
// Throw a more descriptive error
72-
throw new Error(`Token Metrics API Error (${statusCode || 'Unknown'}): ${errorMessage}`);
73-
}
57+
// Generate summary using utility function
58+
const filterSummary = generateFilterSummary(this, endpoint.filters);
59+
60+
// Use $ context for export
61+
const dataLength = response.data?.length || 0;
62+
$.export("$summary", `Successfully retrieved AI reports for ${dataLength} tokens${filterSummary}`);
63+
64+
return response;
7465
},
7566
};
Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import tokenMetrics from "../../token_metrics.app.mjs";
2-
import { ENDPOINTS, FILTER_DEFINITIONS } from "../../common/constants.mjs";
2+
import { ENDPOINTS } from "../../common/constants.mjs";
33
import { buildParams, generateFilterSummary } from "../../common/utils.mjs";
44

55
const endpoint = ENDPOINTS.CORRELATION;
@@ -14,20 +14,30 @@ export default {
1414
tokenMetrics,
1515
// Filter props based on endpoint configuration and API documentation
1616
tokenId: {
17-
...FILTER_DEFINITIONS.token_id,
18-
description: "Comma Separated Token IDs. Click here to access the list of token IDs. Example: 3375,3306",
17+
propDefinition: [
18+
tokenMetrics,
19+
"tokenId",
20+
],
1921
},
2022
symbol: {
21-
...FILTER_DEFINITIONS.symbol,
22-
description: "Comma Separated Token Symbols. Click here to access the list of token symbols. Example: BTC,ETH",
23+
propDefinition: [
24+
tokenMetrics,
25+
"symbol",
26+
],
2327
},
2428
category: {
25-
...FILTER_DEFINITIONS.category,
26-
description: "Comma separated category name. Click here to access the list of categories. Example: layer-1,nft",
29+
propDefinition: [
30+
tokenMetrics,
31+
"category",
32+
],
33+
description: "Select categories to filter results. Example: `layer-1,nft`",
2734
},
2835
exchange: {
29-
...FILTER_DEFINITIONS.exchange,
30-
description: "Comma separated exchange name. Click here to access the list of exchanges. Example: gate,binance",
36+
propDefinition: [
37+
tokenMetrics,
38+
"exchange",
39+
],
40+
description: "Select exchanges to filter results. Example: `gate,binance`",
3141
},
3242
// Pagination props
3343
limit: {
@@ -43,41 +53,26 @@ export default {
4353
tokenMetrics,
4454
"page",
4555
],
46-
description: "Enables pagination and data retrieval control by skipping a specified number of items before fetching data. Page should be a non-negative integer, with 1 indicating the beginning of the dataset. Defaults to 1",
56+
min: 1,
4757
default: 1,
4858
},
4959
},
5060
async run({ $ }) {
5161
// Build parameters using utility function
5262
const params = buildParams(this, endpoint.filters);
5363

54-
try {
55-
const response = await this.tokenMetrics.getCorrelation({
56-
$,
57-
params,
58-
});
64+
const response = await this.tokenMetrics.getCorrelation({
65+
$,
66+
params,
67+
});
5968

60-
// Generate summary using utility function
61-
const filterSummary = generateFilterSummary(this, endpoint.filters);
62-
63-
// Use $ context for export
64-
if ($ && $.export) {
65-
const dataLength = response.data?.length || 0;
66-
$.export("$summary", `Successfully retrieved correlation data for ${dataLength} tokens${filterSummary}`);
67-
}
68-
69-
return response;
70-
} catch (error) {
71-
// Enhanced error handling
72-
const errorMessage = error.response?.data?.message || error.message || "An error occurred";
73-
const statusCode = error.response?.status;
74-
75-
if ($ && $.export) {
76-
$.export("$summary", `Error: ${errorMessage}`);
77-
}
78-
79-
// Throw a more descriptive error
80-
throw new Error(`Token Metrics API Error (${statusCode || 'Unknown'}): ${errorMessage}`);
81-
}
69+
// Generate summary using utility function
70+
const filterSummary = generateFilterSummary(this, endpoint.filters);
71+
72+
// Use $ context for export
73+
const dataLength = response.data?.length || 0;
74+
$.export("$summary", `Successfully retrieved correlation data for ${dataLength} tokens${filterSummary}`);
75+
76+
return response;
8277
},
8378
};
Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import tokenMetrics from "../../token_metrics.app.mjs";
2-
import { ENDPOINTS, FILTER_DEFINITIONS } from "../../common/constants.mjs";
2+
import { ENDPOINTS } from "../../common/constants.mjs";
33
import { buildParams, generateFilterSummary } from "../../common/utils.mjs";
44

55
const endpoint = ENDPOINTS.CRYPTO_INVESTORS;
@@ -26,41 +26,26 @@ export default {
2626
tokenMetrics,
2727
"page",
2828
],
29-
description: "Enables pagination and data retrieval control by skipping a specified number of items before fetching data. Page should be a non-negative integer, with 1 indicating the beginning of the dataset. Defaults to 1",
29+
min: 1,
3030
default: 1,
3131
},
3232
},
3333
async run({ $ }) {
3434
// Build parameters using utility function
3535
const params = buildParams(this, endpoint.filters);
3636

37-
try {
38-
const response = await this.tokenMetrics.getCryptoInvestors({
39-
$,
40-
params,
41-
});
37+
const response = await this.tokenMetrics.getCryptoInvestors({
38+
$,
39+
params,
40+
});
4241

43-
// Generate summary using utility function
44-
const filterSummary = generateFilterSummary(this, endpoint.filters);
45-
46-
// Use $ context for export
47-
if ($ && $.export) {
48-
const dataLength = response.data?.length || 0;
49-
$.export("$summary", `Successfully retrieved ${dataLength} crypto investors${filterSummary}`);
50-
}
51-
52-
return response;
53-
} catch (error) {
54-
// Enhanced error handling
55-
const errorMessage = error.response?.data?.message || error.message || "An error occurred";
56-
const statusCode = error.response?.status;
57-
58-
if ($ && $.export) {
59-
$.export("$summary", `Error: ${errorMessage}`);
60-
}
61-
62-
// Throw a more descriptive error
63-
throw new Error(`Token Metrics API Error (${statusCode || 'Unknown'}): ${errorMessage}`);
64-
}
42+
// Generate summary using utility function
43+
const filterSummary = generateFilterSummary(this, endpoint.filters);
44+
45+
// Use $ context for export
46+
const dataLength = response.data?.length || 0;
47+
$.export("$summary", `Successfully retrieved ${dataLength} crypto investors${filterSummary}`);
48+
49+
return response;
6550
},
6651
};

0 commit comments

Comments
 (0)