Using API

It’s easy to use the Trading Economics API. You can utilize direct endpoints or our packages.

Endpoints

In this documentation, the endpoint examples links will display just the method and the parameters. If you click on one of them, a new browser window will open with a data sample and the complete endpoint. To use them, just copy and paste in an internet browser or any other tool, changing the parameters to what you like.

/country/{country}

Packages

After setting up the Authentication, you can start using the Trading Economics packages or any other server based language.

To use Trading Economics Python Package, just copy any method from the documentation, paste it in your code and change the parameters to what you like.

By default, Python package shows data as json.

te.getIndicatorData(country='mexico')

You can change the output type to dataframe:

te.getIndicatorData(country='mexico', output_type='df')

To use Trading Economics Node Package, just copy any method from the documentation, paste it in your code and change the parameters to what you like.

By default, Node package shows data as json.

data = te.getIndicatorData(country = 'mexico').then(function(data){
  console.log(data)       
});

To use Trading Economics API with any server based language, copy and paste an endpoint and change its parameters to what you like.

By default, Server based languages show data as json.

using System;
using System.IO;
using System.Net;

namespace Examples.System.Net
{
    public class Indicators
    {
        public static void Main()
        {
            WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/country/mexico?c=your_api_key");
            WebResponse response = request.GetResponse(); 
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);    

            using (Stream dataStream = response.GetResponseStream())
            { 
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
            }     
            response.Close();
        }
    }        
}
CountryCategoryTitleLatestValueDateLatestValueSourceSourceURLUnitURLCategoryGroupAdjustmentFrequencyHistoricalDataSymbolCreateDateFirstValueDatePreviousValuePreviousValueDate
MexicoAuto ExportsMexico Auto Exports6/30/2023 12:00:00 AM286.29Instituto Nacional de Estadística y Geografía (INEGI)https://www.inegi.org.mx/Thousand Units/mexico/auto-exportsTradeNSAMonthlyMEXICOAUTEXP7/23/2019 12:20:00 PM1/31/1988 12:00:00 AM279.275/31/2023 12:00:00 AM
MexicoBalance of TradeMexico Balance of Trade5/31/2023 12:00:00 AM-74.00Instituto Nacional de Estadística y Geografía (INEGI)https://www.inegi.org.mx/USD Million/mexico/balance-of-tradeTradeNSAMonthlyMXTBBAL7/25/2014 2:01:00 PM1/31/1980 12:00:00 AM-1509.004/30/2023 12:00:00 AM
MexicoBanks Balance SheetMexico Banks Balance Sheet4/30/2023 12:00:00 AM10335903.02Banco de Méxicohttps://www.banxico.org.mxMXN Million/mexico/banks-balance-sheetTradeNSAMonthlyMEXICOBANBALSHE9/8/2014 3:29:00 PM12/31/2000 12:00:00 AM10169075.643/31/2023 12:00:00 AM

GitHub

You can look for other examples on how to use our API in different programming languages, in our Github repository.