Fix Rates getTicker endpoint - resolve 404 error
The Strike API /rates/ticker endpoint returns all currency pairs in a single response, not individual pairs. Updated the implementation to: - Remove incorrect currency pair parameter from endpoint URL - Fetch all tickers and filter to requested pair client-side - Add "All Currency Pairs" option to get all rates at once - Add BTC/AUD and BTC/USDT currency pair options - Improve error handling when requested pair not found Fixes 404 "Resource not found" error when using Rates > Get Ticker operation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -503,7 +503,27 @@ export class Strike implements INodeType {
|
|||||||
if (resource === 'rates') {
|
if (resource === 'rates') {
|
||||||
if (operation === 'getTicker') {
|
if (operation === 'getTicker') {
|
||||||
const currencyPair = this.getNodeParameter('currencyPair', i) as string;
|
const currencyPair = this.getNodeParameter('currencyPair', i) as string;
|
||||||
responseData = await strikeApiRequest.call(this, 'GET', `/rates/ticker/${currencyPair}`);
|
// The Strike API returns all currency pairs
|
||||||
|
const allTickers = await strikeApiRequest.call(this, 'GET', '/rates/ticker');
|
||||||
|
|
||||||
|
// Filter to the requested currency pair
|
||||||
|
if (currencyPair && currencyPair !== 'all') {
|
||||||
|
// Extract source and target currencies (e.g., 'BTCUSD' -> 'BTC' and 'USD')
|
||||||
|
const sourceCurrency = currencyPair.slice(0, 3);
|
||||||
|
const targetCurrency = currencyPair.slice(3);
|
||||||
|
|
||||||
|
responseData = allTickers.find((ticker: any) =>
|
||||||
|
ticker.sourceCurrency === sourceCurrency &&
|
||||||
|
ticker.targetCurrency === targetCurrency
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!responseData) {
|
||||||
|
responseData = { error: `Currency pair ${currencyPair} not found in available tickers` };
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Return all tickers if 'all' is selected
|
||||||
|
responseData = allTickers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,12 +32,15 @@ export const ratesFields: INodeProperties[] = [
|
|||||||
name: 'currencyPair',
|
name: 'currencyPair',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
options: [
|
options: [
|
||||||
|
{ name: 'All Currency Pairs', value: 'all' },
|
||||||
{ name: 'BTC/USD', value: 'BTCUSD' },
|
{ name: 'BTC/USD', value: 'BTCUSD' },
|
||||||
{ name: 'BTC/EUR', value: 'BTCEUR' },
|
{ name: 'BTC/EUR', value: 'BTCEUR' },
|
||||||
{ name: 'BTC/GBP', value: 'BTCGBP' },
|
{ name: 'BTC/GBP', value: 'BTCGBP' },
|
||||||
|
{ name: 'BTC/AUD', value: 'BTCAUD' },
|
||||||
|
{ name: 'BTC/USDT', value: 'BTCUSDT' },
|
||||||
],
|
],
|
||||||
default: 'BTCUSD',
|
default: 'BTCUSD',
|
||||||
description: 'Currency pair for the ticker',
|
description: 'Currency pair for the ticker. Select "All Currency Pairs" to get rates for all available pairs.',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: ['rates'],
|
resource: ['rates'],
|
||||||
|
|||||||
Reference in New Issue
Block a user