Search Information by Name
Learn to get information about securities using their names.
We'll cover the following
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 |
| required | string | This is the name of the security whose exchange information we are looking for. |
| optional | string | This parameter represents the language in which we want the information, possible values include |
| optional | string | This parameter represents the region for which we want the information. The possible options for this parameter are |
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.
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 |
| This is the type of security we get in response. |
| This is the symbol of the type of security. |
| This is the full name of the security. |
| This is the symbol of security. |
| This is the name of the exchange where the security is listed. |
| This is the symbol of the exchange where the security is listed. |