Search Information by Name

Learn to get information about securities using their names.

So far, we've been using symbols in our endpoints to get information about the securities. But what if the user does not know the security’s symbol and wants to search using the name of the security?

The YH Finance API provides us with an endpoint that gives us basic information about any security using its name. The base URL of this endpoint is https://yfapi.net/v6/finance/autocomplete. We can use information we get in response with the other endpoints to get more details.

Request parameters

We can use the following query parameters with this endpoint.

Parameters

Category

Type

Description

query

required

string

This is the name of the security whose exchange information we are looking for.

lang

optional

string

This parameter represents the language in which we want the information, possible values include en, es, de, fr, it, and zh. The table in the Appendix shows which language each of these symbols represents.

region

optional

string

This parameter represents the region for which we want the information. The possible options for this parameter are AU, CA, DE, ES, FR, GB, HK, IN, IT, and US. The table in the Appendix shows which region each of these symbols represents.

The code below demonstrates how we can use the YH Finance API to get information about any security using its name. Click "Run" to get the required information.

Press + to interact
const endpointUrl = new URL('https://yfapi.net/v6/finance/autocomplete');
const queryParameters = new URLSearchParams({
region:"US",
lang:"en",
query:"Apple" //AAPL is the symbol for Apple Inc.
});
const headerParameters = {
'X-API-KEY': '{{API_KEY}}'
}
const options = {
method: 'GET',
headers: headerParameters
};
async function fetchSecurityInfo() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
printResponse(response);
} catch (error) {
printError(error);
}
}
fetchSecurityInfo();

Let's look at the code:

  • Line 1: We set the URL to https://yfapi.net/v6/finance/autocomplete.

  • Lines 3–7: We add the query parameters.

  • Lines 18–26: We define a function named fetchSecurityInfo() that calls the endpoint and prints the response.

We can replace Apple in line 6 with the name of any other company to get this information for that company.

Response fields

Here are some important output fields:

Response fields

Description

typeDisp

This is the type of security we get in response.

type

This is the symbol of the type of security.

name

This is the full name of the security.

symbol

This is the symbol of security.

exchDisp

This is the name of the exchange where the security is listed.

exch

This is the symbol of the exchange where the security is listed.