pull:初次提交

This commit is contained in:
Yep_Q
2025-09-08 04:48:28 +08:00
parent 5c0619656d
commit f64f498365
11751 changed files with 1953723 additions and 0 deletions

View File

@@ -0,0 +1,686 @@
import type { INodeProperties } from 'n8n-workflow';
export const coinOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['coin'],
},
},
options: [
{
name: 'Candlestick',
value: 'candlestick',
description: 'Get a candlestick open-high-low-close chart for the selected currency',
action: 'Get a candlestick for a coin',
},
{
name: 'Get',
value: 'get',
description: 'Get current data for a coin',
action: 'Get a coin',
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many coins',
action: 'Get many coins',
},
{
name: 'History',
value: 'history',
description: 'Get historical data (name, price, market, stats) at a given date for a coin',
action: 'Get history for a coin',
},
{
name: 'Market',
value: 'market',
description:
'Get prices and market related data for all trading pairs that match the selected currency',
action: 'Get market prices for a coin',
},
{
name: 'Market Chart',
value: 'marketChart',
description:
'Get historical market data include price, market cap, and 24h volume (granularity auto)',
action: 'Get market chart for a coin',
},
{
name: 'Price',
value: 'price',
description:
'Get the current price of any cryptocurrencies in any other supported currencies that you need',
action: 'Get the price for a coin',
},
{
name: 'Ticker',
value: 'ticker',
description: 'Get coin tickers',
action: 'Get the ticker for a coin',
},
],
default: 'getAll',
},
];
export const coinFields: INodeProperties[] = [
{
displayName: 'Search By',
name: 'searchBy',
required: true,
type: 'options',
options: [
{
name: 'Coin ID',
value: 'coinId',
},
{
name: 'Contract Address',
value: 'contractAddress',
},
],
displayOptions: {
show: {
operation: ['get', 'marketChart', 'price'],
resource: ['coin'],
},
},
default: 'coinId',
description: 'Search by coin ID or contract address',
},
{
displayName: 'Coin Name or ID',
name: 'coinId',
required: true,
type: 'options',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getCoins',
},
displayOptions: {
show: {
operation: ['get'],
resource: ['coin'],
},
},
default: '',
placeholder: 'bitcoin',
},
{
displayName: 'Base Currency Name or ID',
name: 'baseCurrency',
required: true,
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCoins',
},
displayOptions: {
show: {
operation: ['candlestick'],
resource: ['coin'],
},
},
default: '',
description:
'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Base Currency Name or ID',
name: 'baseCurrency',
required: true,
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCurrencies',
},
displayOptions: {
show: {
operation: ['market'],
resource: ['coin'],
},
},
default: '',
description:
'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Coin Name or ID',
name: 'coinId',
required: true,
type: 'options',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getCoins',
},
displayOptions: {
show: {
operation: ['ticker', 'history'],
resource: ['coin'],
},
},
default: '',
placeholder: 'bitcoin',
},
{
displayName: 'Base Currency Names or IDs',
name: 'baseCurrencies',
required: true,
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getCoins',
},
displayOptions: {
show: {
operation: ['price'],
resource: ['coin'],
searchBy: ['coinId'],
},
},
default: [],
placeholder: 'bitcoin',
description:
'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Platform ID',
name: 'platformId',
required: true,
displayOptions: {
show: {
operation: ['get', 'marketChart', 'price'],
resource: ['coin'],
searchBy: ['contractAddress'],
},
},
type: 'options',
options: [
{
name: 'Ethereum',
value: 'ethereum',
},
],
default: 'ethereum',
description: 'The ID of the platform issuing tokens',
},
{
displayName: 'Contract Address',
name: 'contractAddress',
required: true,
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['get', 'marketChart'],
resource: ['coin'],
searchBy: ['contractAddress'],
},
},
description: "Token's contract address",
},
{
displayName: 'Contract Addresses',
name: 'contractAddresses',
required: true,
type: 'string',
default: '',
displayOptions: {
show: {
operation: ['price'],
resource: ['coin'],
searchBy: ['contractAddress'],
},
},
description: 'The contract address of tokens, comma-separated',
},
{
displayName: 'Base Currency Name or ID',
name: 'baseCurrency',
required: true,
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCoins',
},
displayOptions: {
show: {
operation: ['marketChart'],
resource: ['coin'],
searchBy: ['coinId'],
},
hide: {
searchBy: ['contractAddress'],
},
},
default: '',
description:
'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Quote Currency Name or ID',
name: 'quoteCurrency',
required: true,
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCurrencies',
},
displayOptions: {
show: {
operation: ['candlestick', 'marketChart'],
resource: ['coin'],
},
},
default: '',
description:
'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Quote Currency Names or IDs',
name: 'quoteCurrencies',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getCurrencies',
},
required: true,
displayOptions: {
show: {
operation: ['price'],
resource: ['coin'],
},
},
default: [],
description:
'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Range (Days)',
name: 'days',
required: true,
type: 'options',
options: [
{
name: '1',
value: '1',
},
{
name: '7',
value: '7',
},
{
name: '14',
value: '14',
},
{
name: '30',
value: '30',
},
{
name: '90',
value: '90',
},
{
name: '180',
value: '180',
},
{
name: '365',
value: '365',
},
{
name: 'Max',
value: 'max',
},
],
displayOptions: {
show: {
operation: ['marketChart', 'candlestick'],
resource: ['coin'],
},
},
default: '',
description: 'Return data for this many days in the past from now',
},
{
displayName: 'Date',
name: 'date',
required: true,
type: 'dateTime',
displayOptions: {
show: {
operation: ['history'],
resource: ['coin'],
},
},
default: '',
description: 'The date of data snapshot',
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: ['getAll', 'market', 'ticker'],
resource: ['coin'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: ['getAll', 'market', 'ticker'],
resource: ['coin'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 500,
},
default: 100,
description: 'Max number of results to return',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
displayOptions: {
show: {
resource: ['coin'],
operation: ['market'],
},
},
options: [
{
displayName: 'Coin IDs',
name: 'ids',
type: 'string',
placeholder: 'bitcoin',
default: '',
description: 'Filter results by comma-separated list of coin ID',
},
{
displayName: 'Category',
name: 'category',
type: 'options',
options: [
{
name: 'Decentralized Finance Defi',
value: 'decentralized_finance_defi',
},
],
default: 'decentralized_finance_defi',
description: 'Filter by coin category',
},
{
displayName: 'Order',
name: 'order',
type: 'options',
options: [
{
name: 'Gecko Asc',
value: 'gecko_asc',
},
{
name: 'Gecko Desc',
value: 'gecko_desc',
},
{
name: 'ID Asc',
value: 'id_asc',
},
{
name: 'ID Desc',
value: 'id_desc',
},
{
name: 'Market Cap Asc',
value: 'market_cap_asc',
},
{
name: 'Market Cap Desc',
value: 'market_cap_desc',
},
{
name: 'Volume Asc',
value: 'volume_asc',
},
{
name: 'Volume Desc',
value: 'volume_desc',
},
],
default: '',
description: 'Sort results by field',
},
{
displayName: 'Sparkline',
name: 'sparkline',
type: 'boolean',
default: false,
description: 'Whether to include sparkline 7 days data',
},
{
displayName: 'Price Change Percentage',
name: 'price_change_percentage',
type: 'multiOptions',
// eslint-disable-next-line n8n-nodes-base/node-param-multi-options-type-unsorted-items
options: [
{
name: '1h',
value: '1h',
},
{
name: '24h',
value: '24h',
},
{
name: '7d',
value: '7d',
},
{
name: '14d',
value: '14d',
},
{
name: '30d',
value: '30d',
},
{
name: '200d',
value: '200d',
},
{
name: '1y',
value: '1y',
},
],
default: [],
description: 'Include price change percentage for specified times',
},
],
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['coin'],
operation: ['price'],
},
},
options: [
{
displayName: 'Include 24hr Change',
name: 'include_24hr_change',
type: 'boolean',
default: false,
},
{
displayName: 'Include 24hr Vol',
name: 'include_24hr_vol',
type: 'boolean',
default: false,
},
{
displayName: 'Include Last Updated At',
name: 'include_last_updated_at',
type: 'boolean',
default: false,
},
{
displayName: 'Include Market Cap',
name: 'include_market_cap',
type: 'boolean',
default: false,
},
],
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
displayOptions: {
show: {
resource: ['coin'],
operation: ['ticker'],
},
},
options: [
{
displayName: 'Exchange Names or IDs',
name: 'exchange_ids',
type: 'multiOptions',
typeOptions: {
loadOptionsMethod: 'getExchanges',
},
default: [],
description:
'Filter results by exchange IDs. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Include Exchange Logo',
name: 'include_exchange_logo',
type: 'boolean',
default: false,
},
{
displayName: 'Order',
name: 'order',
type: 'options',
options: [
{
name: 'Trust Score Desc',
value: 'trust_score_desc',
},
{
name: 'Trust Score Asc',
value: 'trust_score_asc',
},
{
name: 'Volume Desc',
value: 'volume_desc',
},
],
default: 'trust_score_desc',
description: 'Sorts results by the selected rule',
},
],
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
displayOptions: {
show: {
resource: ['coin'],
operation: ['history'],
},
},
options: [
{
displayName: 'Localization',
name: 'localization',
type: 'boolean',
default: true,
description: 'Whether to exclude localized languages in response',
},
],
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
operation: ['get'],
resource: ['coin'],
},
},
options: [
{
displayName: 'Community Data',
name: 'community_data',
type: 'boolean',
default: false,
description: 'Whether to include community data',
},
{
displayName: 'Developer Data',
name: 'developer_data',
type: 'boolean',
default: false,
description: 'Whether to include developer data',
},
{
displayName: 'Localization',
name: 'localization',
type: 'boolean',
default: false,
description: 'Whether to include all localized languages in response',
},
{
displayName: 'Market Data',
name: 'market_data',
type: 'boolean',
default: false,
description: 'Whether to include market data',
},
{
displayName: 'Sparkline',
name: 'sparkline',
type: 'boolean',
default: false,
description: 'Whether to include sparkline 7 days data (eg. true, false).',
},
{
displayName: 'Tickers',
name: 'tickers',
type: 'boolean',
default: false,
description: 'Whether to include tickers data',
},
],
},
];

View File

@@ -0,0 +1,20 @@
{
"node": "n8n-nodes-base.coinGecko",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": ["Productivity", "Finance & Accounting"],
"resources": {
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.coingecko/"
}
],
"generic": [
{
"label": "2021: The Year to Automate the New You with n8n",
"icon": "☀️",
"url": "https://n8n.io/blog/2021-the-year-to-automate-the-new-you-with-n8n/"
}
]
}
}

View File

@@ -0,0 +1,489 @@
import moment from 'moment-timezone';
import type {
IExecuteFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeExecutionData,
INodePropertyOptions,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import { NodeConnectionTypes } from 'n8n-workflow';
import { coinFields, coinOperations } from './CoinDescription';
import { eventFields, eventOperations } from './EventDescription';
import { coinGeckoApiRequest, coinGeckoRequestAllItems } from './GenericFunctions';
export class CoinGecko implements INodeType {
description: INodeTypeDescription = {
displayName: 'CoinGecko',
name: 'coinGecko',
icon: 'file:coinGecko.svg',
group: ['output'],
version: 1,
description: 'Consume CoinGecko API',
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
defaults: {
name: 'CoinGecko',
},
usableAsTool: true,
inputs: [NodeConnectionTypes.Main],
outputs: [NodeConnectionTypes.Main],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Coin',
value: 'coin',
},
{
name: 'Event',
value: 'event',
},
],
default: 'coin',
},
...coinOperations,
...coinFields,
...eventOperations,
...eventFields,
],
};
methods = {
loadOptions: {
async getCurrencies(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const currencies = await coinGeckoApiRequest.call(
this,
'GET',
'/simple/supported_vs_currencies',
);
currencies.sort();
for (const currency of currencies) {
returnData.push({
name: currency.toUpperCase(),
value: currency,
});
}
return returnData;
},
async getCoins(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const coins = await coinGeckoApiRequest.call(this, 'GET', '/coins/list');
for (const coin of coins) {
returnData.push({
name: coin.symbol.toUpperCase(),
value: coin.id,
});
}
returnData.sort((a, b) => {
if (a.name < b.name) {
return -1;
}
if (a.name > b.name) {
return 1;
}
return 0;
});
return returnData;
},
async getExchanges(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const exchanges = await coinGeckoApiRequest.call(this, 'GET', '/exchanges/list');
for (const exchange of exchanges) {
returnData.push({
name: exchange.name,
value: exchange.id,
});
}
return returnData;
},
async getEventCountryCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const countryCodes = await coinGeckoApiRequest.call(this, 'GET', '/events/countries');
for (const code of countryCodes.data) {
if (!code.code) {
continue;
}
returnData.push({
name: code.country,
value: code.code,
});
}
return returnData;
},
async getEventTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const eventTypes = await coinGeckoApiRequest.call(this, 'GET', '/events/types');
for (const type of eventTypes.data) {
returnData.push({
name: type,
value: type,
});
}
return returnData;
},
},
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: INodeExecutionData[] = [];
const length = items.length;
const qs: IDataObject = {};
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < length; i++) {
try {
if (resource === 'coin') {
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id_
//https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address_
if (operation === 'get') {
const options = this.getNodeParameter('options', i);
qs.community_data = false;
qs.developer_data = false;
qs.localization = false;
qs.market_data = false;
qs.sparkline = false;
qs.tickers = false;
Object.assign(qs, options);
const searchBy = this.getNodeParameter('searchBy', i) as string;
if (searchBy === 'coinId') {
const coinId = this.getNodeParameter('coinId', i) as string;
responseData = await coinGeckoApiRequest.call(
this,
'GET',
`/coins/${coinId}`,
{},
qs,
);
}
if (searchBy === 'contractAddress') {
const platformId = this.getNodeParameter('platformId', i) as string;
const contractAddress = this.getNodeParameter('contractAddress', i) as string;
responseData = await coinGeckoApiRequest.call(
this,
'GET',
`/coins/${platformId}/contract/${contractAddress}`,
{},
qs,
);
}
}
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins_list
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i);
let limit;
responseData = await coinGeckoApiRequest.call(this, 'GET', '/coins/list', {}, qs);
if (!returnAll) {
limit = this.getNodeParameter('limit', i);
responseData = responseData.splice(0, limit);
}
}
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins_list
if (operation === 'market') {
const returnAll = this.getNodeParameter('returnAll', i);
const baseCurrency = this.getNodeParameter('baseCurrency', i) as string;
const options = this.getNodeParameter('options', i);
qs.vs_currency = baseCurrency;
Object.assign(qs, options);
if (options.price_change_percentage) {
qs.price_change_percentage = (options.price_change_percentage as string[]).join(',');
}
if (returnAll) {
responseData = await coinGeckoRequestAllItems.call(
this,
'',
'GET',
'/coins/markets',
{},
qs,
);
} else {
const limit = this.getNodeParameter('limit', i);
qs.per_page = limit;
responseData = await coinGeckoApiRequest.call(this, 'GET', '/coins/markets', {}, qs);
}
}
//https://www.coingecko.com/api/documentations/v3#/simple/get_simple_price
//https://www.coingecko.com/api/documentations/v3#/simple/get_simple_token_price__id_
if (operation === 'price') {
const searchBy = this.getNodeParameter('searchBy', i) as string;
const quoteCurrencies = this.getNodeParameter('quoteCurrencies', i) as string[];
const options = this.getNodeParameter('options', i);
qs.vs_currencies = quoteCurrencies.join(',');
Object.assign(qs, options);
if (searchBy === 'coinId') {
const baseCurrencies = this.getNodeParameter('baseCurrencies', i) as string[];
qs.ids = baseCurrencies.join(',');
responseData = await coinGeckoApiRequest.call(this, 'GET', '/simple/price', {}, qs);
}
if (searchBy === 'contractAddress') {
const platformId = this.getNodeParameter('platformId', i) as string;
const contractAddresses = this.getNodeParameter('contractAddresses', i) as string;
qs.contract_addresses = contractAddresses;
responseData = await coinGeckoApiRequest.call(
this,
'GET',
`/simple/token_price/${platformId}`,
{},
qs,
);
}
}
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__tickers
if (operation === 'ticker') {
const returnAll = this.getNodeParameter('returnAll', i);
const coinId = this.getNodeParameter('coinId', i) as string;
const options = this.getNodeParameter('options', i);
Object.assign(qs, options);
if (options.exchange_ids) {
qs.exchange_ids = (options.exchange_ids as string[]).join(',');
}
if (returnAll) {
responseData = await coinGeckoRequestAllItems.call(
this,
'tickers',
'GET',
`/coins/${coinId}/tickers`,
{},
qs,
);
} else {
const limit = this.getNodeParameter('limit', i);
responseData = await coinGeckoApiRequest.call(
this,
'GET',
`/coins/${coinId}/tickers`,
{},
qs,
);
responseData = responseData.tickers;
responseData = responseData.splice(0, limit);
}
}
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__history
if (operation === 'history') {
const coinId = this.getNodeParameter('coinId', i) as string;
const date = this.getNodeParameter('date', i) as string;
const options = this.getNodeParameter('options', i);
Object.assign(qs, options);
qs.date = moment(date).format('DD-MM-YYYY');
responseData = await coinGeckoApiRequest.call(
this,
'GET',
`/coins/${coinId}/history`,
{},
qs,
);
}
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__market_chart
//https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address__market_chart_
if (operation === 'marketChart') {
let respData;
const searchBy = this.getNodeParameter('searchBy', i) as string;
const quoteCurrency = this.getNodeParameter('quoteCurrency', i) as string;
const days = this.getNodeParameter('days', i) as string;
qs.vs_currency = quoteCurrency;
qs.days = days;
if (searchBy === 'coinId') {
const coinId = this.getNodeParameter('baseCurrency', i) as string;
respData = await coinGeckoApiRequest.call(
this,
'GET',
`/coins/${coinId}/market_chart`,
{},
qs,
);
}
if (searchBy === 'contractAddress') {
const platformId = this.getNodeParameter('platformId', i) as string;
const contractAddress = this.getNodeParameter('contractAddress', i) as string;
respData = await coinGeckoApiRequest.call(
this,
'GET',
`/coins/${platformId}/contract/${contractAddress}/market_chart`,
{},
qs,
);
}
responseData = [];
for (let idx = 0; idx < respData.prices.length; idx++) {
const [time, price] = respData.prices[idx];
const marketCaps = respData.market_caps[idx][1];
const totalVolume = respData.total_volumes[idx][1];
responseData.push({
time: moment(time as string).toISOString(),
price,
marketCaps,
totalVolume,
} as IDataObject);
}
}
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__ohlc
if (operation === 'candlestick') {
const baseCurrency = this.getNodeParameter('baseCurrency', i) as string;
const quoteCurrency = this.getNodeParameter('quoteCurrency', i) as string;
const days = this.getNodeParameter('days', i) as string;
qs.vs_currency = quoteCurrency;
qs.days = days;
responseData = await coinGeckoApiRequest.call(
this,
'GET',
`/coins/${baseCurrency}/ohlc`,
{},
qs,
);
for (let idx = 0; idx < responseData.length; idx++) {
const [time, open, high, low, close] = responseData[idx];
responseData[idx] = {
time: moment(time as string).toISOString(),
open,
high,
low,
close,
} as IDataObject;
}
}
}
if (resource === 'event') {
//https://www.coingecko.com/api/documentations/v3#/events/get_events
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i);
const options = this.getNodeParameter('options', i);
Object.assign(qs, options);
if (returnAll) {
responseData = await coinGeckoRequestAllItems.call(
this,
'data',
'GET',
'/events',
{},
qs,
);
} else {
const limit = this.getNodeParameter('limit', i);
qs.per_page = limit;
responseData = await coinGeckoApiRequest.call(this, 'GET', '/events', {}, qs);
responseData = responseData.data;
}
}
}
if (resource === 'simple') {
//https://www.coingecko.com/api/documentations/v3#/simple/get_simple_price
if (operation === 'price') {
const ids = this.getNodeParameter('ids', i) as string;
const currencies = this.getNodeParameter('currencies', i) as string[];
const options = this.getNodeParameter('options', i);
qs.ids = ids;
qs.vs_currencies = currencies.join(',');
Object.assign(qs, options);
responseData = await coinGeckoApiRequest.call(this, 'GET', '/simple/price', {}, qs);
}
//https://www.coingecko.com/api/documentations/v3#/simple/get_simple_token_price__id_
if (operation === 'tokenPrice') {
const id = this.getNodeParameter('id', i) as string;
const contractAddresses = this.getNodeParameter('contractAddresses', i) as string;
const currencies = this.getNodeParameter('currencies', i) as string[];
const options = this.getNodeParameter('options', i);
qs.contract_addresses = contractAddresses;
qs.vs_currencies = currencies.join(',');
Object.assign(qs, options);
responseData = await coinGeckoApiRequest.call(
this,
'GET',
`/simple/token_price/${id}`,
{},
qs,
);
}
}
const executionData = this.helpers.constructExecutionMetaData(
this.helpers.returnJsonArray(responseData as IDataObject[]),
{ itemData: { item: i } },
);
returnData.push(...executionData);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message, json: {} });
continue;
}
throw error;
}
}
return [returnData];
}
}

View File

@@ -0,0 +1,117 @@
import type { INodeProperties } from 'n8n-workflow';
export const eventOperations: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['event'],
},
},
options: [
{
name: 'Get Many',
value: 'getAll',
description: 'Get many events',
action: 'Get many events',
},
],
default: 'getAll',
},
];
export const eventFields: INodeProperties[] = [
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['event'],
},
},
default: false,
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
operation: ['getAll'],
resource: ['event'],
returnAll: [false],
},
},
typeOptions: {
minValue: 1,
maxValue: 500,
},
default: 100,
description: 'Max number of results to return',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add option',
default: {},
displayOptions: {
show: {
operation: ['getAll'],
resource: ['event'],
},
},
options: [
{
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-options
displayName: 'Country Code',
name: 'country_code',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getEventCountryCodes',
},
default: '',
description:
'Country code of event. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'From Date',
name: 'from_date',
type: 'dateTime',
default: '',
description: 'Lists events after this date',
},
{
displayName: 'To Date',
name: 'to_date',
type: 'dateTime',
default: '',
description: 'Lists events before this date',
},
{
displayName: 'Type Name or ID',
name: 'type',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getEventTypes',
},
default: '',
description:
'Type of event. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
},
{
displayName: 'Upcoming Events Only',
name: 'upcoming_events_only',
type: 'boolean',
default: true,
description: 'Whether to list only upcoming events',
},
],
},
];

View File

@@ -0,0 +1,73 @@
import type {
IExecuteFunctions,
ILoadOptionsFunctions,
IDataObject,
JsonObject,
IHttpRequestMethods,
IRequestOptions,
} from 'n8n-workflow';
import { NodeApiError } from 'n8n-workflow';
export async function coinGeckoApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: IHttpRequestMethods,
endpoint: string,
body: any = {},
qs: IDataObject = {},
uri?: string,
option: IDataObject = {},
): Promise<any> {
let options: IRequestOptions = {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
method,
body,
qs,
uri: uri || `https://api.coingecko.com/api/v3${endpoint}`,
json: true,
};
options = Object.assign({}, options, option);
try {
if (Object.keys(body as IDataObject).length === 0) {
delete options.body;
}
return await this.helpers.request.call(this, options);
} catch (error) {
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}
export async function coinGeckoRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions,
propertyName: string,
method: IHttpRequestMethods,
endpoint: string,
body: any = {},
query: IDataObject = {},
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
let respData;
query.per_page = 250;
query.page = 1;
do {
responseData = await coinGeckoApiRequest.call(this, method, endpoint, body, query);
query.page++;
respData = responseData;
if (propertyName !== '') {
respData = responseData[propertyName];
}
returnData.push.apply(returnData, respData as IDataObject[]);
} while (respData.length !== 0);
return returnData;
}

View File

@@ -0,0 +1,9 @@
{
"type": "object",
"properties": {
"time": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1,101 @@
{
"type": "object",
"properties": {
"additional_notices": {
"type": "array",
"items": {
"type": "string"
}
},
"block_time_in_minutes": {
"type": "integer"
},
"categories": {
"type": "array",
"items": {
"type": "string"
}
},
"description": {
"type": "object",
"properties": {
"en": {
"type": "string"
}
}
},
"id": {
"type": "string"
},
"image": {
"type": "object",
"properties": {
"large": {
"type": "string"
},
"small": {
"type": "string"
},
"thumb": {
"type": "string"
}
}
},
"links": {
"type": "object",
"properties": {
"chat_url": {
"type": "array",
"items": {
"type": "string"
}
},
"homepage": {
"type": "array",
"items": {
"type": "string"
}
},
"official_forum_url": {
"type": "array",
"items": {
"type": "string"
}
},
"repos_url": {
"type": "object",
"properties": {
"github": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"twitter_screen_name": {
"type": "string"
},
"whitepaper": {
"type": "string"
}
}
},
"name": {
"type": "string"
},
"preview_listing": {
"type": "boolean"
},
"symbol": {
"type": "string"
},
"watchlist_portfolio_users": {
"type": "integer"
},
"web_slug": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1,15 @@
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"symbol": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1,576 @@
{
"type": "object",
"properties": {
"community_data": {
"type": "object",
"properties": {
"facebook_likes": {
"type": "null"
},
"reddit_average_comments_48h": {
"type": "integer"
},
"reddit_average_posts_48h": {
"type": "integer"
},
"reddit_subscribers": {
"type": "null"
}
}
},
"developer_data": {
"type": "object",
"properties": {
"closed_issues": {
"type": "null"
},
"code_additions_deletions_4_weeks": {
"type": "object",
"properties": {
"additions": {
"type": "null"
},
"deletions": {
"type": "null"
}
}
},
"commit_count_4_weeks": {
"type": "null"
},
"forks": {
"type": "null"
},
"pull_request_contributors": {
"type": "null"
},
"pull_requests_merged": {
"type": "null"
},
"stars": {
"type": "null"
},
"subscribers": {
"type": "null"
},
"total_issues": {
"type": "null"
}
}
},
"id": {
"type": "string"
},
"image": {
"type": "object",
"properties": {
"small": {
"type": "string"
},
"thumb": {
"type": "string"
}
}
},
"localization": {
"type": "object",
"properties": {
"ar": {
"type": "string"
},
"bg": {
"type": "string"
},
"cs": {
"type": "string"
},
"da": {
"type": "string"
},
"de": {
"type": "string"
},
"el": {
"type": "string"
},
"en": {
"type": "string"
},
"es": {
"type": "string"
},
"fi": {
"type": "string"
},
"fr": {
"type": "string"
},
"he": {
"type": "string"
},
"hi": {
"type": "string"
},
"hr": {
"type": "string"
},
"hu": {
"type": "string"
},
"id": {
"type": "string"
},
"it": {
"type": "string"
},
"ja": {
"type": "string"
},
"ko": {
"type": "string"
},
"lt": {
"type": "string"
},
"nl": {
"type": "string"
},
"no": {
"type": "string"
},
"pl": {
"type": "string"
},
"pt": {
"type": "string"
},
"ro": {
"type": "string"
},
"ru": {
"type": "string"
},
"sk": {
"type": "string"
},
"sl": {
"type": "string"
},
"sv": {
"type": "string"
},
"th": {
"type": "string"
},
"tr": {
"type": "string"
},
"uk": {
"type": "string"
},
"vi": {
"type": "string"
},
"zh": {
"type": "string"
},
"zh-tw": {
"type": "string"
}
}
},
"market_data": {
"type": "object",
"properties": {
"current_price": {
"type": "object",
"properties": {
"aed": {
"type": "number"
},
"ars": {
"type": "number"
},
"aud": {
"type": "number"
},
"bch": {
"type": "number"
},
"bdt": {
"type": "number"
},
"bhd": {
"type": "number"
},
"bits": {
"type": "number"
},
"bmd": {
"type": "number"
},
"bnb": {
"type": "number"
},
"brl": {
"type": "number"
},
"cad": {
"type": "number"
},
"chf": {
"type": "number"
},
"clp": {
"type": "number"
},
"cny": {
"type": "number"
},
"czk": {
"type": "number"
},
"dkk": {
"type": "number"
},
"dot": {
"type": "number"
},
"eos": {
"type": "number"
},
"eth": {
"type": "number"
},
"eur": {
"type": "number"
},
"gbp": {
"type": "number"
},
"gel": {
"type": "number"
},
"hkd": {
"type": "number"
},
"huf": {
"type": "number"
},
"idr": {
"type": "number"
},
"ils": {
"type": "number"
},
"inr": {
"type": "number"
},
"jpy": {
"type": "number"
},
"krw": {
"type": "number"
},
"kwd": {
"type": "number"
},
"link": {
"type": "number"
},
"lkr": {
"type": "number"
},
"ltc": {
"type": "number"
},
"mmk": {
"type": "number"
},
"mxn": {
"type": "number"
},
"myr": {
"type": "number"
},
"ngn": {
"type": "number"
},
"nok": {
"type": "number"
},
"nzd": {
"type": "number"
},
"php": {
"type": "number"
},
"pkr": {
"type": "number"
},
"pln": {
"type": "number"
},
"rub": {
"type": "number"
},
"sar": {
"type": "number"
},
"sats": {
"type": "number"
},
"sek": {
"type": "number"
},
"sgd": {
"type": "number"
},
"thb": {
"type": "number"
},
"try": {
"type": "number"
},
"twd": {
"type": "number"
},
"uah": {
"type": "number"
},
"usd": {
"type": "number"
},
"vef": {
"type": "number"
},
"vnd": {
"type": "number"
},
"xag": {
"type": "number"
},
"xau": {
"type": "number"
},
"xdr": {
"type": "number"
},
"xlm": {
"type": "number"
},
"xrp": {
"type": "number"
},
"yfi": {
"type": "number"
},
"zar": {
"type": "number"
}
}
},
"total_volume": {
"type": "object",
"properties": {
"aed": {
"type": "number"
},
"aud": {
"type": "number"
},
"bch": {
"type": "number"
},
"bdt": {
"type": "number"
},
"bhd": {
"type": "number"
},
"bits": {
"type": "number"
},
"bmd": {
"type": "number"
},
"bnb": {
"type": "number"
},
"brl": {
"type": "number"
},
"btc": {
"type": "number"
},
"cad": {
"type": "number"
},
"chf": {
"type": "number"
},
"clp": {
"type": "number"
},
"cny": {
"type": "number"
},
"czk": {
"type": "number"
},
"dkk": {
"type": "number"
},
"dot": {
"type": "number"
},
"eos": {
"type": "number"
},
"eth": {
"type": "number"
},
"eur": {
"type": "number"
},
"gbp": {
"type": "number"
},
"gel": {
"type": "number"
},
"hkd": {
"type": "number"
},
"huf": {
"type": "number"
},
"ils": {
"type": "number"
},
"inr": {
"type": "number"
},
"jpy": {
"type": "number"
},
"krw": {
"type": "number"
},
"kwd": {
"type": "number"
},
"link": {
"type": "number"
},
"lkr": {
"type": "number"
},
"ltc": {
"type": "number"
},
"mmk": {
"type": "number"
},
"mxn": {
"type": "number"
},
"myr": {
"type": "number"
},
"ngn": {
"type": "number"
},
"nok": {
"type": "number"
},
"nzd": {
"type": "number"
},
"php": {
"type": "number"
},
"pkr": {
"type": "number"
},
"pln": {
"type": "number"
},
"rub": {
"type": "number"
},
"sar": {
"type": "number"
},
"sats": {
"type": "number"
},
"sek": {
"type": "number"
},
"sgd": {
"type": "number"
},
"thb": {
"type": "number"
},
"try": {
"type": "number"
},
"twd": {
"type": "number"
},
"uah": {
"type": "number"
},
"usd": {
"type": "number"
},
"vef": {
"type": "number"
},
"xag": {
"type": "number"
},
"xau": {
"type": "number"
},
"xdr": {
"type": "number"
},
"xlm": {
"type": "number"
},
"xrp": {
"type": "number"
},
"yfi": {
"type": "number"
},
"zar": {
"type": "number"
}
}
}
}
},
"name": {
"type": "string"
},
"public_interest_stats": {
"type": "object",
"properties": {
"alexa_rank": {
"type": "null"
},
"bing_matches": {
"type": "null"
}
}
},
"symbol": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1,33 @@
{
"type": "object",
"properties": {
"ath_date": {
"type": "string"
},
"atl_change_percentage": {
"type": "number"
},
"atl_date": {
"type": "string"
},
"id": {
"type": "string"
},
"image": {
"type": "string"
},
"last_updated": {
"type": "string"
},
"market_cap": {
"type": "integer"
},
"name": {
"type": "string"
},
"symbol": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1,12 @@
{
"type": "object",
"properties": {
"time": {
"type": "string"
},
"totalVolume": {
"type": "number"
}
},
"version": 1
}

View File

@@ -0,0 +1,16 @@
{
"type": "object",
"properties": {
"nacho-the-kat": {
"type": "object",
"properties": {
"usd": {
"type": "number"
}
},
"required": [
"usd"
]
}
}
}

View File

@@ -0,0 +1,67 @@
{
"type": "object",
"properties": {
"base": {
"type": "string"
},
"coin_id": {
"type": "string"
},
"converted_last": {
"type": "object",
"properties": {
"btc": {
"type": "number"
},
"eth": {
"type": "number"
}
}
},
"is_anomaly": {
"type": "boolean"
},
"is_stale": {
"type": "boolean"
},
"last": {
"type": "number"
},
"last_fetch_at": {
"type": "string"
},
"last_traded_at": {
"type": "string"
},
"market": {
"type": "object",
"properties": {
"has_trading_incentive": {
"type": "boolean"
},
"identifier": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"target": {
"type": "string"
},
"target_coin_id": {
"type": "string"
},
"timestamp": {
"type": "string"
},
"token_info_url": {
"type": "null"
},
"trade_url": {
"type": "string"
}
},
"version": 1
}

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 276 276"><defs><style>.cls-3{fill:#fff}.cls-4{fill:#8bc53f}.cls-6{fill:#58595b}</style></defs><g id="Coin_Gecko_AI" data-name="Coin Gecko AI"><path fill="#8dc63f" d="M276 137.39A138 138 0 1 1 137.39 0 138 138 0 0 1 276 137.39"/><path fill="#f9e988" d="M265.65 137.44a127.63 127.63 0 1 1-128.21-127 127.65 127.65 0 0 1 128.21 127"/><path d="M140.35 18.66a70.2 70.2 0 0 1 24.53 0 74.8 74.8 0 0 1 23.43 7.85c7.28 4 13.57 9.43 19.83 14.52s12.49 10.3 18.42 16a93.3 93.3 0 0 1 15.71 19 108.3 108.3 0 0 1 11 22.17c5.33 15.66 7.18 32.53 4.52 48.62H257c-2.67-15.95-6.29-31.15-12-45.61A177.5 177.5 0 0 0 235.56 80a209 209 0 0 0-12.42-20 72.3 72.3 0 0 0-16.64-16.8c-6.48-4.62-13.93-7.61-21.14-10.45S171 27 163.48 24.84s-15.16-3.78-23.14-5.35z" class="cls-3"/><path d="M202.74 92.39c-9.26-2.68-18.86-6.48-28.58-10.32-.56-2.44-2.72-5.48-7.09-9.19-6.35-5.51-18.28-5.37-28.59-2.93-11.38-2.68-22.62-3.63-33.41-1-88.25 24.31-38.21 83.62-70.61 143.24 4.61 9.78 54.3 66.84 126.2 51.53 0 0-24.59-59.09 30.9-87.45 45.01-23.09 77.53-65.81 11.18-83.88" class="cls-4"/><path d="M213.64 131.2a5.35 5.35 0 1 1-5.38-5.32 5.36 5.36 0 0 1 5.38 5.32" class="cls-3"/><path fill="#009345" d="M138.48 69.91c6.43.46 29.68 8 35.68 12.12-5-14.5-21.83-16.43-35.68-12.12"/><path d="M144.6 106.58a24.68 24.68 0 1 1-24.69-24.67 24.68 24.68 0 0 1 24.68 24.66z" class="cls-3"/><path d="M137.28 106.8a17.36 17.36 0 1 1-17.36-17.36 17.36 17.36 0 0 1 17.36 17.36" class="cls-6"/><path d="M233.63 142.08c-20 14.09-42.74 24.78-75 24.78-15.1 0-18.16-16-28.14-8.18-5.15 4.06-23.31 13.14-37.72 12.45S55 162 48.49 131.23C45.91 162 44.59 184.65 33 210.62c23 36.83 77.84 65.24 127.62 53-5.31-37.35 27.38-73.93 45.72-92.62 7-7.09 20.3-18.66 27.29-28.91z" class="cls-4"/><path d="M232.85 143c-6.21 5.66-13.6 9.85-21.12 13.55a135 135 0 0 1-23.7 8.63c-8.16 2.11-16.67 3.7-25.29 2.92s-17.43-3.71-23.14-10.17l.27-.31c7 4.54 15.08 6.14 23.12 6.37a108.3 108.3 0 0 0 24.3-2 132.7 132.7 0 0 0 23.61-7.3c7.63-3.15 15.18-6.8 21.68-12z" class="cls-6"/></g></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB