'Investpy: pass the stocks code and receive the ISIN in the return

I recently discovered the investpy library and I would like to know if there is any function where I can pass the stocks code and on return, among other data, receive its ISIN. I'm trying the functionsearch_quotes, but the ISIN doesn't come back.

import investpy as ip
search = ip.search_quotes(text='CPLE11')
for s in search:
    print(s)

If anyone knows of any other library where I can pass the code and receive the ISIN, that helps too.



Solution 1:[1]

You can get the ISIN by symbol as follows:

import investpy
symbol = "TSLA"
df = investpy.search_stocks(by='symbol', value=symbol)
df = df[df.symbol == symbol]
print(df)

However the code does not work for the symbol you provided. You have to find the correct symbol by mapping it.

EDIT: It might also be the case that this specific company cannot be found using this API. I tried to find it with the following code:

stocks = stocks = investpy.stocks.get_stocks()
matches = [_ for idx, _ in stocks.iterrows() if _["name"].startswith("Companhia")]
print([m["name"] for m in matches])

Your stock is not among the matches.

Solution 2:[2]

You can use the openfigi API https://www.openfigi.com/api

Value   ID_ISIN 
Description
ISIN - International Securities Identification Number.

Example:
[{"idType":"ID_ISIN","idValue":"XX1234567890"}]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Aavesh