Unable to access StockTwits API from Express App hosted in Google App Engine

331 Views Asked by At

I am able to access the StockTwits publicly available API: https://api.stocktwits.com/api/2/streams/symbol/:id.json from my express app when trying from local machine.

However, whenever I try to host the app from Google App Engine, I get the below error:

2020-04-29 17:24:46 default[20200428t231015]  [0mGET /WMT [0m- [0m- ms - -[0m
2020-04-29 17:24:46 default[20200428t231015]  Calling the stock-twits API: https://api.stocktwits.com/api/2/streams/symbol/WMT.json
2020-04-29 17:24:46 default[20200428t231015]  Response {
2020-04-29 17:24:46 default[20200428t231015]    size: 0,
2020-04-29 17:24:46 default[20200428t231015]    timeout: 0,
2020-04-29 17:24:46 default[20200428t231015]    [Symbol(Body internals)]:
2020-04-29 17:24:46 default[20200428t231015]     { body:
2020-04-29 17:24:46 default[20200428t231015]        PassThrough {
2020-04-29 17:24:46 default[20200428t231015]          _readableState: [ReadableState],
2020-04-29 17:24:46 default[20200428t231015]          readable: true,
2020-04-29 17:24:46 default[20200428t231015]          _events: [Object],
2020-04-29 17:24:46 default[20200428t231015]          _eventsCount: 6,
2020-04-29 17:24:46 default[20200428t231015]          _maxListeners: undefined,
2020-04-29 17:24:46 default[20200428t231015]          _writableState: [WritableState],
2020-04-29 17:24:46 default[20200428t231015]          writable: true,
2020-04-29 17:24:46 default[20200428t231015]          allowHalfOpen: true,
2020-04-29 17:24:46 default[20200428t231015]          _transformState: [Object] },
2020-04-29 17:24:46 default[20200428t231015]       disturbed: false,
2020-04-29 17:24:46 default[20200428t231015]       error: null },
2020-04-29 17:24:46 default[20200428t231015]    [Symbol(Response internals)]:
2020-04-29 17:24:46 default[20200428t231015]     { url:
2020-04-29 17:24:46 default[20200428t231015]        'https://api.stocktwits.com/api/2/streams/symbol/WMT.json',
2020-04-29 17:24:46 default[20200428t231015]       status: 503,
2020-04-29 17:24:46 default[20200428t231015]       statusText: 'Service Temporarily Unavailable',
2020-04-29 17:24:46 default[20200428t231015]       headers: Headers { [Symbol(map)]: [Object] },
2020-04-29 17:24:46 default[20200428t231015]       counter: 0 } }
2020-04-29 17:24:46 default[20200428t231015]  Encountered the below error while fetching from the url: https://api.stocktwits.com/api/2/streams/symbol/ric/WMT.json
2020-04-29 17:24:46 default[20200428t231015]  ERROR: FetchError: invalid json response body at https://api.stocktwits.com/api/2/streams/symbol/WMT.json reason: Unexpected token < in JSON at position 0

Is there something special I need to take care for using the app if I host on Google App Engine?

1

There are 1 best solutions below

0
Andrew Homeyer On

Same issue, even for authenticated requests. I wouldn't be surprised if the IP range from app engine is blocked due to a bad actor spamming the StockTwits API.