4

I am using the Alpha Vantage API and have come across a problem, every time I try to send an API request where the symbol (ticker) has a "." in it, the API call returns an Invalid API call error.

How do I get past this?

For example, to search for BT Group on the London Stock Exchange, you would use "LON:BT.A" which I would expect the formulate the URL like below:

https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=LON:BT.A&apikey=API_KEY

This does not work, but equally if I wanted to search for a ticker without a dot then it works perfectly fine, for example Sky plc is "LON:SKY" so the below works:

https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=LON:SKY&apikey=API_KEY
jww
  • 97,681
  • 90
  • 411
  • 885
KillerKode
  • 957
  • 1
  • 12
  • 31
  • 1
    Possible duplicate of [How to URL encode periods?](https://stackoverflow.com/q/6191412/608639) – jww Sep 18 '18 at 07:21

2 Answers2

2

Most of the tickers that have a "." in them seem to require that you replace them with a "-", so this worked for me, however I have found that this is not always the case. I couldn't find any documentation with a comprehensive list of tickers (I guess probably because it's dynamic) so stopped using the API.

KillerKode
  • 957
  • 1
  • 12
  • 31
  • I've tried the following, to no avail: CCC.U CCC_U CCC-U CCC+U CCC%2DU CCC%2EU – alfadog67 Apr 08 '19 at 21:42
  • &symbol=NYSE:CCC seems to work for me. I have not used the Alpha Vantage API in a good while, it may be better now but I couldn't find consistency in the tickers so have stopped using it. – KillerKode Apr 09 '19 at 07:09
  • Yes I'm sure it does. My example pertains to CCC.U, or any symbol containing punctuation. – alfadog67 Apr 10 '19 at 12:23
  • Oh sorry, I did a quick Google and thought CCC was same as CCC.U. Which company is this exactly? If I check CCC-U it shows a result too, not sure if it is the same company though. – KillerKode Apr 10 '19 at 12:26
  • Interesting... CCC-U for me won't work, it's returning "Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for TIME_SERIES_DAILY." Could you post your URL (minus your key) so that I can follow up? BTW, CCC.U is Churchill Capital Corp. – alfadog67 Apr 10 '19 at 16:49
  • Here's my link: https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&outputsize=compact&datatype=csv&apikey=MyKey&symbol=CCC-U Of course with MyKey being replaced with my key ;-) – alfadog67 Apr 10 '19 at 16:54
  • Well I used this URL: https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=CCC-U&apikey=API_KEY - it works fine and seems to return the correct price for Churchill. However, when I tried this yesterday at my home network, it did not. But, this morning at my work network it seems to work fine. Another point of unreliability for this API. It seems the API does a partial string search on the symbol parameter, so it is not exact match, that is part of the problem in my opinion. – KillerKode Apr 11 '19 at 07:12
  • 1
    Interesting... I run that and get the same API failure. Thanks for posting it... I'm afraid that quotes for securities with punctuation are unobtainable from alphavantage. I have a request in, but I feel it's final resting place is on their deep, dark hard drive of hopelessness. – alfadog67 Apr 11 '19 at 16:26
0

You could URL-Encode the dot as %2E. Same technique as encoding a space as %20. Your URL would look like this with the encoded dot:

https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=LON:BT%2EA&apikey=API_KEY

More information about URL-Encoding can be found here:
https://www.w3schools.com/tags/ref_urlencode.asp

Still wondering why the plain dot is not allowed in the URL though. Think the webserver just cannot handle it. According to RFC3986 paragraph 2.3 dots are allowed and don't have any special meaning.

Community
  • 1
  • 1
Bouke
  • 1,531
  • 1
  • 12
  • 21
  • Yes, I managed to figure it out. Even the %2E did not work, it turns out this API replaces all "dot" symbols with a "-" instead (if the symbol is in the middle of the ticker). Pretty annoying, took me a while to figure out as it is not documented. – KillerKode Sep 18 '18 at 20:17
  • Wouldn't have expected that unconventional behavior. Strange they didn't document it, a dot in trading symbols is very common. – Bouke Sep 19 '18 at 10:02
  • Doesn't work. Have used SYMBOL_SEARCH for URBI. I then try to query TIME_SERIES_DAILY_ADJUSTED for URBI.MEX (tried URBI.MX, URBI-MEX, URBI-MX) and get an Invalid API call... – Molasar Nov 17 '19 at 18:53