# Search the API

> The following endpoints allow you to search on the Trading Economics API.

Source: https://docs.tradingeconomics.com/searching/

You can search by keyword, term, or category. If you do not know which category to look for, just use the search/{term} endpoint option.

> **Note:** The response fields returned depend on the search results.

**PYTHON**
*Using Requests:*
```python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/search/gold?c={your_api_key}'
data = requests.get(url).json()
print(data)
```
*Or using our package:*
```python
import tradingeconomics as te
te.login('your_api_key')
te.getSearch(term  = 'gold')
```

**JS**
*Using Requests:*
```js
const axios = require('axios');
(async () => {
    const your_api_key = 'your_api_key'
    const response = await axios.get(`https://api.tradingeconomics.com/search/gold?c=${your_api_key}`)
    console.log(response.data)
})()
```
*Or using our package:*
```javascript
const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getSearch(term = 'gold').then(function(data){
    console.log(data)     
});
```

**C#**
*Using Requests:*
```c#
using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/search/gold?c=your_api_key"))
    {
        request.Headers.TryAddWithoutValidation("Upgrade-Insecure-Requests", "1");
        var response = await httpClient.SendAsync(request);
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync(); 
            Console.WriteLine(content);
        }
    }
}
```

The response data format can be configured by appending the **&f=** parameter to the URL request.

**JSON**
```text
https://api.tradingeconomics.com/search/{term}?c={your_api_key}&f=json
```
```json
[
  {
    "Symbol": "CHINAGOLRES"
  },
  {
    "Symbol": "EUROAREAGOLRES"
  },
  {
    "Symbol": "GERMANYGOLRES"
  },
  {
    "Symbol": "XAUUSD:CUR"
  }
]
```

**CSV**
```text
https://api.tradingeconomics.com/search/{term}?c={your_api_key}&f=csv
```
```bash
CHINAGOLRES,Gold Reserves,China,2113.46,Quarterly,Tonnes,,China Gold Reserves,/china/gold-reserves,Economic,13,Aug  7 2023  9:48AM
EUROAREAGOLRES,Gold Reserves,Euro Area,506.52,Quarterly,Tonnes,,Euro Area Gold Reserves,/euro-area/gold-reserves,Economic,13,Aug 14 2023 11:21AM
GERMANYGOLRES,Gold Reserves,Germany,3352.65,Quarterly,Tonnes,,Germany Gold Reserves,/germany/gold-reserves,Economic,13,Aug  8 2023  1:52AM
XAUUSD:CUR,commodity,commodity,1856.100000000000,Live,USD/t.oz, ,commodity commodity,/commodity/gold,markets,6,Oct 10 2023  1:50PM
```

**HTML**
```text
https://api.tradingeconomics.com/search/{term}?c={your_api_key}
```

| Symbol | Category | Country | LatestValue | Frequency | Unit | Currency | Title | Url | Type | Importance | LastUpdate |
|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
| CHINAGOLRES | Gold Reserves | China | 2068.36 | Quarterly | Tonnes | | China Gold Reserves | /china/gold-reserves | Economic | 13 | May 5 2023 9:35PM |
| EUROAREAGOLRES | Gold Reserves | Euro Area | 506.52 | Quarterly | Tonnes | |Euro Area Gold Reserves | /euro-area/gold-reserves | Economic | 13 | May 5 2023 9:35PM |
| GERMANYGOLRES | Gold Reserves | Germany | 3354.89 | Quarterly | Tonnes | | Germany Gold Reserves | /germany/gold-reserves | Economic | 13 | May 5 2023 9:35PM |

## List of categories

List all categories available for searching

**PYTHON**
*Using Requests:*
```python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/search/categories?c={your_api_key}'
data = requests.get(url).json()
print(data)
```
*Or using our package:*
```python
te.getSearch()
```

**JS**
*Using Requests:*
```js
const axios = require('axios');
(async () => {
    const your_api_key = 'your_api_key'
    const response = await axios.get(`https://api.tradingeconomics.com/search/categories?c=${your_api_key}`)
    console.log(response.data)
})()
```
*Or using our package:*
```javascript
data = te.getSearch().then(function(data){
    console.log(data)     
});
```

**C#**
*Using Requests:*
```c#
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/search/categories?c=your_api_key");
```

**JSON**
```text
https://api.tradingeconomics.com/search/categories?c={your_api_key}&f=json
```
```json
[
  {
    "Categories": "Markets"
  },
  {
    "Categories": "Commodity"
  },
  {
    "Categories": "Currency"
  },
  {
    "Categories": "Index"
  },
  {
    "Categories": "Economic"
  },
  {
    "Categories": "Comtrade"
  },
  {
    "Categories": "Worldbank - wb"
  },
  {
    "Categories": "Federal Reserve - fred"
  }
]
```

**CSV**
```text
https://api.tradingeconomics.com/search/categories?c={your_api_key}&f=csv
```
```bash
Markets
Commodity
Currency
Index
```

**HTML**
```text
https://api.tradingeconomics.com/search/categories?c={your_api_key}
```

| Categories |
|-------|
| Markets |
| Commodity |
| Currency |
| Index |
| Economic |
| Comtrade |
| Worldbank - wb |
| Federal Reserve - fred |

## By term and category

**PYTHON**
*Using Requests:*
```python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/search/japan?category=markets&c={your_api_key}'
data = requests.get(url).json()
print(data)
```
*Or using our package:*
```python
te.getSearch(term  = 'japan', category = 'markets')
```

**JS**
*Using Requests:*
```js
const axios = require('axios');
(async () => {
    const your_api_key = 'your_api_key'
    const response = await axios.get(`https://api.tradingeconomics.com/search/japan?category=markets&c=${your_api_key}`)
    console.log(response.data)
})()
```
*Or using our package:*
```javascript
data = te.getSearch(term = 'japan', category = 'markets').then(function(data){
    console.log(data)     
});
```

**C#**
*Using Requests:*
```c#
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/search/japan?category=markets&c=your_api_key");
```

**JSON**
```text
https://api.tradingeconomics.com/search/{term}?c={your_api_key}&category={category}&f=json
```
```json
[
  {
    "Symbol": "GJGB10:IND",
    "Ticker": "GJGB10",
    "Name": "Japan 10Y",
    "Country": "Japan",
    "Date": "2023-10-10T13:59:37",
    "Type": "bond",
    "decimals": null,
    "state": null,
    "Last": null,
    "Close": null,
    "CloseDate": null,
    "MarketCap": null,
    "URL": "/japan/government-bond-yield",
    "Importance": null,
    "DailyChange": null,
    "DailyPercentualChange": null,
    "WeeklyChange": null,
    "WeeklyPercentualChange": null,
    "MonthlyChange": null,
    "MonthlyPercentualChange": null,
    "YearlyChange": null,
    "YearlyPercentualChange": null,
    "YTDChange": null,
    "YTDPercentualChange": null,
    "day_high": null,
    "day_low": null
  }
]
```

**CSV**
```text
https://api.tradingeconomics.com/search/{term}?c={your_api_key}&category={category}&f=csv
```
```bash
GJGB10:IND,GJGB10,Japan 10Y,Japan,10/10/2023 1:59:37 PM,bond,,,,,,,/japan/government-bond-yield,,,,,,,,,,,,,,,,,,,,,Delayed,
GJGB1M:IND,GJGB1M,Japan 1M,Japan,10/10/2023 12:00:00 AM,bond,,,,,,,/japan/1-month-bill-yield,,,,,,,,,,,,,,,,,,,,,Daily,
GJGB1Y:IND,GJGB1Y,Japan 52W,Japan,10/10/2023 11:05:27 AM,bond,,,,,,,/japan/52-week-bill-yield,,,,,,,,,,,,,,,,,,,,,Delayed,
```

**HTML**
```text
https://api.tradingeconomics.com/search/{term}?c={your_api_key}&category={category}
```

| Symbol | Ticker	| Name | Country | Date	| Type | decimals | state | Last | Close | CloseDate | MarketCap | URL | Importance | DailyChange | DailyPercentualChange | WeeklyChange | WeeklyPercentualChange | MonthlyChange | MonthlyPercentualChange | YearlyChange | YearlyPercentualChange | YTDChange | YTDPercentualChange | day_high | day_low | yesterday | lastWeek | lastMonth | lastYear | startYear | ISIN | unit | frequency | LastUpdate |
|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
| GJGB10:IND | GJGB10 | Japan 10Y | Japan | 7/14/2023 12:20:13 PM | bond | | | | | | | /japan/government-bond-yield | | | | | | | | | | | | | | | | | | | | | Delayed |
| GJGB1M:IND | GJGB1M | Japan 1M | Japan | 7/14/2023 12:00:00 AM | bond | | | | | | | /japan/1-month-bill-yield | | | | | | | | | | | | | | | | | | | | | Daily	|
| GJGB1Y:IND | GJGB1Y | Japan 52W | Japan | 7/14/2023 12:19:42 PM | bond | | | | | | | /japan/52-week-bill-yield | | | | | | | | | | | | | | | | | | | | | Delayed	|

