### Install Trading Economics Python Package Source: https://docs.tradingeconomics.com/get_started Installs the tradingeconomics Python package using pip. This package provides access to the Trading Economics API. Ensure you have a recent version of Python installed. ```bash pip install tradingeconomics ``` -------------------------------- ### Install Trading Economics JS Package Source: https://docs.tradingeconomics.com/get_started Installs the tradingeconomics Node.js package using npm. This package enables access to the Trading Economics API from JavaScript applications. A recent version of Node.js is required. ```bash npm install tradingeconomics ``` -------------------------------- ### Fetch Earnings and Revenues Data (C#, HTTP Request) Source: https://docs.tradingeconomics.com/financials/earnings_revenues Constructs an HTTP GET request message to fetch earnings and revenues data for a specified start date. This example shows the message creation, not the execution of the request. Requires an API key. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/earnings-revenues?c=your_api_key&d1=2017-01-01"); ``` -------------------------------- ### Setup Node.js Client for Streaming News Source: https://docs.tradingeconomics.com/news/streaming These commands outline the process for setting up a Node.js client to stream news from the TradingEconomics API. It involves cloning the repository, navigating to the example directory, installing dependencies, and configuring the client with API credentials in the app.js file. ```bash git clone https://github.com/tradingeconomics/tradingeconomics-js ``` ```bash cd tradingeconomics-js/Examples/stream-nodejs/ ``` ```bash npm install ``` ```javascript Client = new te_client({ url: 'wss://stream.tradingeconomics.com/', key: 'API_CLIENT_KEY', // <-- secret: 'API_CLIENT_SECRET' // <-- //reconnect: true }); Client.subscribe('news') ``` -------------------------------- ### Install Node.js dependencies for the streaming example Source: https://docs.tradingeconomics.com/economic_calendar/streaming This command installs all the necessary Node.js packages required for the streaming example to function correctly. It reads the dependencies listed in the package.json file within the current directory. ```bash npm install ``` -------------------------------- ### Fetch Economic Data using Node.js Axios Source: https://docs.tradingeconomics.com/get_started This example demonstrates fetching economic data for Mexico using Node.js and the 'axios' library. It includes authentication using an API key in the URL and logging the response data. The data format can be modified to XML or CSV by appending '&f=format' to the URL. ```JavaScript const axios = require('axios'); (async () => { const api_key = 'YOUR_API_KEY' const response = await axios.get(`https://api.tradingeconomics.com/country/mexico?c=${api_key}`) console.log(response.data) })() ``` ```JavaScript const response = await axios.get(`https://api.tradingeconomics.com/country/mexico?c=${api_key}&f=xml`) ``` ```JavaScript (async () => { const url = 'https://api.tradingeconomics.com/country/mexico'; const headers = { 'Authorization': 'api_key' }; try { const response = await fetch(url, { method: 'GET', headers }); const data = await response.text(); console.log(data); } catch (error) { console.error(error); } })(); ``` -------------------------------- ### GET /country/{country} Source: https://docs.tradingeconomics.com/get_started Retrieves economic data for a specified country. The response format can be customized using the 'f' query parameter. ```APIDOC ## GET /country/{country} ### Description Retrieves economic data for a specified country. The response format can be customized using the 'f' query parameter. ### Method GET ### Endpoint `/country/{country}` ### Parameters #### Path Parameters - **country** (string) - Required - The country for which to retrieve data. #### Query Parameters - **f** (string) - Optional - The desired format for the response data. Supported values: HTML, JSON, CSV, XML. ### Request Example `GET /country/mexico?f=json` ### Response #### Success Response (200) - **Country** (string) - The name of the country. - **Category** (string) - The category of the economic indicator. - **Title** (string) - The title of the economic indicator. - **LatestValueDate** (string) - The date of the latest recorded value. - **LatestValue** (number) - The latest recorded value. - **Source** (string) - The source of the data. - **SourceURL** (string) - The URL of the data source. - **Unit** (string) - The unit of measurement for the value. - **URL** (string) - The API endpoint URL for this indicator. - **CategoryGroup** (string) - The group the category belongs to. - **Adjustment** (string) - Data adjustment type (e.g., NSA for Not Seasonally Adjusted). - **Frequency** (string) - The frequency of the data (e.g., Monthly). - **HistoricalDataSymbol** (string) - A symbol representing the historical data. - **CreateDate** (string) - The date the record was created. - **FirstValueDate** (string) - The date of the first recorded value. - **PreviousValue** (number) - The previous recorded value. - **PreviousValueDate** (string) - The date of the previous recorded value. #### Response Example (JSON) ```json [ { "Country": "Mexico", "Category": "Auto Exports", "Title": "Mexico Auto Exports", "LatestValueDate": "2023-08-31T00:00:00", "LatestValue": 287.85, "Source": "Instituto Nacional de EstadĂ­stica y GeografĂ­a (INEGI)", "SourceURL": "https://www.inegi.org.mx/", "Unit": "Thousand Units", "URL": "/mexico/auto-exports", "CategoryGroup": "Trade", "Adjustment": "NSA", "Frequency": "Monthly", "HistoricalDataSymbol": "MEXICOAUTEXP", "CreateDate": "2019-07-23T12:20:00", "FirstValueDate": "1988-01-31T00:00:00", "PreviousValue": 275.77, "PreviousValueDate": "2023-07-31T00:00:00" } ] ``` ``` -------------------------------- ### Fetch Earnings and Revenues Data with Date Range (C#, HTTP Request) Source: https://docs.tradingeconomics.com/financials/earnings_revenues Constructs an HTTP GET request message to fetch earnings and revenues data within a specified start and end date. This example shows the message creation, not the execution. Requires an API key. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/earnings-revenues?c=your_api_key&d1=2017-01-01&d2=2017-12-31"); ``` -------------------------------- ### Create HTTP Request Message for Forecast Data in C# Source: https://docs.tradingeconomics.com/forecasts/indicators Constructs an HTTP GET request message to fetch forecast data for specified countries and indicators using C#. This example uses a hardcoded 'guest' API key and demonstrates the setup of the request object. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/forecast/country/mexico,sweden/indicator/gdp,population?c=guest:guest"); ``` -------------------------------- ### Get Total Exports by Country (C# Requests) Source: https://docs.tradingeconomics.com/comtrade/snapshot Demonstrates initiating a GET request to retrieve total export data for a country using C#'s HttpClient. This example shows the setup of the HttpRequestMessage with the API endpoint URL and requires your API key. ```csharp using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/export/india/totals?c=your_api_key")) ``` -------------------------------- ### Get Total Imports by Country (C# Requests) Source: https://docs.tradingeconomics.com/comtrade/snapshot Demonstrates initiating a GET request to retrieve total import data for a country using C#'s HttpClient. This example shows the setup of the HttpRequestMessage with the API endpoint URL and requires your API key. ```csharp using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/import/india/totals?c=your_api_key")) ``` -------------------------------- ### Get Country Data (C#) Source: https://docs.tradingeconomics.com/get_started This endpoint retrieves economic indicators for a specific country using C#. You can configure the response format and pass your API key either in the URL or via request headers. ```APIDOC ## GET /country/{country_code} ### Description Retrieves economic indicators for a specified country. ### Method GET ### Endpoint `https://api.tradingeconomics.com/country/{country_code}` ### Parameters #### Query Parameters - **c** (string) - Required - Your API key. - **f** (string) - Optional - Response data format (e.g., `json`, `xml`, `csv`). Defaults to `json`. ### Request Example ```csharp using (var httpClient = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/country/mexico?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); } } } ``` ### Response #### Success Response (200) - **Data** (array) - An array of economic indicator objects. #### Response Example ```json { "example": "[response body]" } ``` ### Configuring Response Format ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/country/mexico?c=your_api_key&f=xml") ``` ``` -------------------------------- ### Get Country Data in XML Format Source: https://docs.tradingeconomics.com/get_started This snippet shows how to request economic data for a specific country in XML format. It involves appending '?f=xml' to the base country URL. The output is an XML document containing the data. ```xml NSA Auto Exports Trade Mexico 2019-07-23T12:20:00 1988-01-31T00:00:00 ``` -------------------------------- ### Fetch County Data by State using C# HttpRequestMessage Source: https://docs.tradingeconomics.com/federal_reserve/snapshot Demonstrates fetching county-level FRED data for a state using C# with `HttpRequestMessage`. This example outlines the setup for making a GET request to the Trading Economics API, requiring manual construction of the URL and inclusion of the API key. The `using` statement ensures proper disposal of the request object. ```csharp using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/fred/snapshot/county/arkansas?c=your_api_key")) { // Further request execution logic would go here } ``` -------------------------------- ### Get Country Data (Python) Source: https://docs.tradingeconomics.com/get_started This endpoint retrieves economic indicators for a specific country. You can configure the response format and pass your API key either in the URL or via request headers. ```APIDOC ## GET /country/{country_code} ### Description Retrieves economic indicators for a specified country. ### Method GET ### Endpoint `https://api.tradingeconomics.com/country/{country_code}` ### Parameters #### Query Parameters - **c** (string) - Required - Your API key. - **f** (string) - Optional - Response data format (e.g., `json`, `xml`, `csv`). Defaults to `json`. ### Request Example ```python import requests api_key = 'YOUR_API_KEY' url = f'https://api.tradingeconomics.com/country/mexico?c={api_key}' data = requests.get(url).json() print(data) ``` ### Response #### Success Response (200) - **Data** (array) - An array of economic indicator objects. #### Response Example ```json { "example": "[response body]" } ``` ### Using Request Headers for API Key ```python import requests response = requests.get('https://api.tradingeconomics.com/country/mexico', headers = {'Authorization': 'api_key'}) print(response.json()) ``` ### Configuring Response Format ```python url = f'https://api.tradingeconomics.com/country/mexico?c={api_key}&f=xml' ``` ``` -------------------------------- ### Get Country Data (JavaScript) Source: https://docs.tradingeconomics.com/get_started This endpoint retrieves economic indicators for a specific country using JavaScript. You can configure the response format and pass your API key either in the URL or via request headers. ```APIDOC ## GET /country/{country_code} ### Description Retrieves economic indicators for a specified country. ### Method GET ### Endpoint `https://api.tradingeconomics.com/country/{country_code}` ### Parameters #### Query Parameters - **c** (string) - Required - Your API key. - **f** (string) - Optional - Response data format (e.g., `json`, `xml`, `csv`). Defaults to `json`. ### Request Example ```javascript const axios = require('axios'); (async () => { const api_key = 'YOUR_API_KEY' const response = await axios.get(`https://api.tradingeconomics.com/country/mexico?c=${api_key}`) console.log(response.data) })() ``` ### Response #### Success Response (200) - **Data** (array) - An array of economic indicator objects. #### Response Example ```json { "example": "[response body]" } ``` ### Using Request Headers for API Key ```javascript (async () => { const url = 'https://api.tradingeconomics.com/country/mexico'; const headers = { 'Authorization': 'api_key' }; try { const response = await fetch(url, { method: 'GET', headers }); const data = await response.text(); console.log(data); } catch (error) { console.error(error); } })(); ``` ### Configuring Response Format ```javascript const response = await axios.get(`https://api.tradingeconomics.com/country/mexico?c=${api_key}&f=xml`) ``` ``` -------------------------------- ### Get World Bank Indicator Data - C# Source: https://docs.tradingeconomics.com/world_bank/snapshot Demonstrates how to make an HTTP GET request to retrieve World Bank indicator data using C#. This example uses 'HttpClient' and requires manual construction of the request URL and headers. ```csharp using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/worldbank/indicator?url=/united-states/real-interest-rate-percent-wb-data.html&c=your_api_key")) { // Additional request configuration can go here } ``` -------------------------------- ### C#: Fetch Calendar Data by Ticker (HttpClient) Source: https://docs.tradingeconomics.com/economic_calendar/ticker Demonstrates fetching economic calendar data by ticker using C#'s HttpClient. This example shows how to make a GET request to the API for a single ticker, and a separate example illustrates constructing a URL for multiple tickers. ```csharp using (var httpClient = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/calendar/ticker/IJCUSA?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); } } } ``` ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/calendar/ticker/IJCUSA,SPAINFACORD,BAHRAININFNRATE?c=your_api_key"); ``` -------------------------------- ### Get Stock Descriptions by Country (C# - HttpRequestMessage) Source: https://docs.tradingeconomics.com/markets/description Constructs an HTTP GET request to fetch stock descriptions for a specified country using C#. This example shows the basic request setup. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/markets/stockdescriptions/country/france?c=your_api_key"); ``` -------------------------------- ### Set up and Subscribe to Market Data Streams (JavaScript/Node.js) Source: https://docs.tradingeconomics.com/markets/streaming This section provides instructions for setting up the JavaScript streaming client for Node.js. It covers cloning the repository, navigating to the example directory, installing dependencies, configuring API keys in `userKey.js`, and subscribing to market data streams. ```bash git clone https://github.com/tradingeconomics/tradingeconomics-js ``` ```bash cd tradingeconomics-js/Examples/stream-nodejs/ ``` ```bash npm install ``` ```javascript Client = new te_client({ url: 'wss://stream.tradingeconomics.com/', key: 'API_CLIENT_KEY', // <-- secret: 'API_CLIENT_SECRET' // <-- //reconnect: true }); Client.subscribe('EURUSD:CUR') ``` ```javascript Client.subscribe(['EURUSD:CUR', 'AAPL:US', 'CL1:COM']) ``` -------------------------------- ### Get IPO by Ticker using C# HttpRequestMessage Source: https://docs.tradingeconomics.com/financials/ipo Constructs an HTTP GET request to fetch IPO data for a specific ticker using C#. This example demonstrates basic HTTP request setup, requiring manual handling of API key and response processing. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/ipo/ticker/RRKA?c=your_api_key"); ``` -------------------------------- ### Navigate to the Node.js streaming example directory Source: https://docs.tradingeconomics.com/economic_calendar/streaming After cloning the repository, this command changes the current directory to the Node.js streaming example folder within the Trading Economics JavaScript client library. This is where you will find the necessary files to set up the streaming client. ```bash cd tradingeconomics-js/Examples/stream-nodejs/ ``` -------------------------------- ### Fetch Stock Splits by Country (C#) Source: https://docs.tradingeconomics.com/financials/stock-split Demonstrates initiating an HTTP GET request to retrieve stock split data for a country. This example shows the request setup using HttpRequestMessage. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/splits/country/india?c=your_api_key"); ``` -------------------------------- ### Fetch Indicator Data with JavaScript Source: https://docs.tradingeconomics.com/get_started Fetches indicator data for a specified country using the Trading Economics Node.js package. The process includes importing the package, authenticating with an API key, and using the getIndicatorData function within a promise to handle the asynchronous response. Data is returned as an array of JavaScript objects. ```javascript const te = require('tradingeconomics'); te.login('your_api_key'); data = te.getIndicatorData(country = 'mexico').then(function(data){ }); ``` -------------------------------- ### Paginate News List with C# HttpRequestMessage Source: https://docs.tradingeconomics.com/news/latest Constructs an HTTP GET request to the Trading Economics API for paginating news data in C#. This example shows how to set up the request URL with parameters for API key, limit, and start index. ```C# new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/news?c=your_api_key&limit=5&start=150"); ``` -------------------------------- ### C#: Fetch country trade by type using HttpRequestMessage Source: https://docs.tradingeconomics.com/comtrade/snapshot Constructs an HTTP GET request to retrieve trade data (import/export) between two countries. This example demonstrates the setup for making the API call using C#'s HttpRequestMessage. ```csharp using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=import&c=your_api_key")) ``` ```csharp using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=export&c=your_api_key")) ``` -------------------------------- ### Create HTTP Request for GDP Data in C# Source: https://docs.tradingeconomics.com/indicators/snapshot Constructs an HTTP GET request message to fetch GDP data for Mexico using C#'s HttpClient. This example demonstrates setting up the request but does not include sending it or handling the response. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/country/mexico?c=your_api_key&group=gdp"); ``` -------------------------------- ### Fetch Economic Data using C# HttpClient Source: https://docs.tradingeconomics.com/get_started This C# code snippet illustrates how to retrieve economic data using `HttpClient`. It shows how to construct the HTTP request, include the API key in the URL, and read the response content as a string. The response format can be changed to XML or CSV by modifying the URL. ```C# using (var httpClient = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/country/mexico?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); } } } ``` ```C# new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/country/mexico?c=your_api_key&f=xml") ``` -------------------------------- ### Fetch State Data (C#) using HttpRequestMessage Source: https://docs.tradingeconomics.com/federal_reserve/snapshot Demonstrates fetching state-level FRED snapshot data using C# with `HttpRequestMessage`. This example shows the basic setup for making a GET request to the Trading Economics API. Replace 'your_api_key' with your actual API key. ```csharp using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/fred/snapshot/state/tennessee?c=your_api_key")) { // Additional request configuration can be added here } ``` -------------------------------- ### Fetch Economic Data using Python Requests Source: https://docs.tradingeconomics.com/get_started This snippet shows how to fetch economic data for a specific country (Mexico) using the Python 'requests' library. It demonstrates basic API key authentication via URL parameters and printing the JSON response. The response format can be changed to XML or CSV. ```Python import requests api_key = 'YOUR_API_KEY' url = f'https://api.tradingeconomics.com/country/mexico?c={api_key}' data = requests.get(url).json() print(data) ``` ```Python url = f'https://api.tradingeconomics.com/country/mexico?c={api_key}&f=xml' ``` ```Python import requests response = requests.get('https://api.tradingeconomics.com/country/mexico', headers = {'Authorization': 'api_key'}) print(response.json()) ``` -------------------------------- ### Fetch Indicator Data with Python Source: https://docs.tradingeconomics.com/get_started Fetches indicator data for a specified country using the Trading Economics Python package. This involves importing the package, logging in with an API key, and calling the getIndicatorData function. The output can be a list of dictionaries or a Pandas DataFrame. ```python import tradingeconomics as te te.login('your_api_key') data = te.getIndicatorData(country='mexico') ``` ```python import tradingeconomics as te te.login('your_api_key') data = te.getIndicatorData(country='mexico', output_type='df') ``` -------------------------------- ### Get Dividends Data (Python Package) Source: https://docs.tradingeconomics.com/financials/dividends Retrieves dividend data using the Trading Economics Python package. This method simplifies data fetching by abstracting API calls. Requires start and end dates. Assumes the 'te' package is installed and configured. ```python te.getDividends(startDate='2023-01-01', endDate='2024-01-01') ``` -------------------------------- ### Fetch IPO Data by Country and Date - C# Source: https://docs.tradingeconomics.com/financials/ipo Illustrates how to initiate an HTTP GET request to fetch IPO data using C#'s `HttpClient` class. This example focuses on setting up the request message with the necessary URL and API key. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/ipo/country/india?d1=2023-09-01&d2=2023-12-01&c=your_api_key"); ``` -------------------------------- ### Get News by Date using Python (Requests & Package) Source: https://docs.tradingeconomics.com/news/by-parameter Fetch news articles by date using Python. It includes examples for making direct HTTP requests with the 'requests' library and using the official 'tradingeconomics' package. Both methods require an API key and specify start and end dates. ```python import requests api_key = 'YOUR_API_KEY' url = f'https://api.tradingeconomics.com/news?c={api_key}&d1=2021-02-02&d2=2021-03-03' data = requests.get(url).json() print(data) ``` ```python import tradingeconomics as te te.login('your_api_key') te.getNews(start_date = '2021-02-02', end_date = '2021-03-03') ``` -------------------------------- ### Fetch Earnings/Revenue by Country (C#) Source: https://docs.tradingeconomics.com/financials/earnings_revenues Provides an example of initiating an HTTP GET request to fetch earnings and revenue data for a country using C#. This snippet demonstrates constructing the request message. ```C# new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/earnings-revenues/country/mexico?c=your_api_key"); ``` -------------------------------- ### Get Historical Financial Data (JavaScript) Source: https://docs.tradingeconomics.com/financials/historical Fetch historical financial data for a specified symbol and category over a date range using JavaScript. This example shows how to use the 'axios' library for HTTP requests and the Trading Economics package. Make sure 'axios' is installed and replace 'YOUR_API_KEY' with your valid API key. ```javascript const axios = require('axios'); (async () => { const api_key = 'YOUR_API_KEY' const response = await axios.get(`https://api.tradingeconomics.com/financials/historical/aapl:us:assets?d1=2022-01-01&d2=2023-01-01&c=${api_key}`) console.log(response.data) })() ``` ```javascript data = te.getFinancialsHistorical(symbol = 'aapl:us', category = 'assets', start_date = '2022-01-01', end_date = '2023-01-01').then(function(data){ console.log(data) }); ``` -------------------------------- ### Clone the repository for Trading Economics JavaScript examples Source: https://docs.tradingeconomics.com/economic_calendar/streaming This command clones the official Trading Economics JavaScript client library repository from GitHub. This repository contains various examples, including how to implement real-time data streaming. ```bash git clone https://github.com/tradingeconomics/tradingeconomics-js ``` -------------------------------- ### GET /earnings-revenues (With Start Date) Source: https://docs.tradingeconomics.com/financials/earnings_revenues Retrieve earnings and revenues data starting from a specific date. Supports Python, JavaScript, and C#. ```APIDOC ## GET /earnings-revenues?d1={start_date} ### Description Retrieves earnings and revenues data from a specified start date. ### Method GET ### Endpoint `/earnings-revenues` ### Parameters #### Query Parameters - **d1** (string, required) - The start date in 'yyyy-mm-dd' format. - **c** (string, required) - Your API key. ### Request Example (Python - Requests) ```python import requests api_key = 'YOUR_API_KEY' url = f'https://api.tradingeconomics.com/earnings-revenues?c={api_key}&d1=2017-01-01' data = requests.get(url).json() print(data) ``` ### Request Example (JavaScript - Axios) ```javascript const axios = require('axios'); (async () => { const api_key = 'YOUR_API_KEY' const response = await axios.get(`https://api.tradingeconomics.com/earnings-revenues?c=${api_key}&d1=2017-01-01`) console.log(response.data) })() ``` ### Request Example (C# - HttpRequestMessage) ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/earnings-revenues?c=your_api_key&d1=2017-01-01"); ``` ### Response #### Success Response (200) - **Date** (string) - The date of the earnings/revenue report. - **Symbol** (string) - The stock symbol. - **Name** (string) - The company name. - **Actual** (number) - The actual reported earnings per share. - **ActualValue** (number) - The actual reported earnings value. - **Forecast** (number) - The forecasted earnings per share. - **ForecastValue** (number) - The forecasted earnings value. - **Previous** (number) - The previous period's earnings per share. - **PreviousValue** (number) - The previous period's earnings value. - **Revenue** (number) - The actual reported revenue. - **RevenueValue** (number) - The actual reported revenue value. - **RevenueForecast** (number) - The forecasted revenue. - **RevenueForecastValue** (number) - The forecasted revenue value. - **RevenuePrevious** (number) - The previous period's revenue. - **RevenuePreviousValue** (number) - The previous period's revenue value. - **MarketCapUSD** (number) - The market capitalization in USD. - **FiscalTag** (string) - The fiscal quarter/year tag. - **FiscalReference** (string) - The fiscal reference period. - **CalendarReference** (string) - The calendar reference period. - **Country** (string) - The country of the company. - **Currency** (string) - The currency of the company's stock. - **Importance** (integer) - The importance score of the data point. - **Session** (string) - The trading session. - **MarketRelease** (string) - When the market release occurred. - **LastUpdate** (string) - The last update timestamp. ### Response Example (JSON) ```json { "Date": "2017-01-04", "Symbol": "RECN:US", "Name": "Resources Connection", "Actual": 0.18, "ActualValue": 0.18, "Forecast": 0.19, "ForecastValue": 0.19, "Previous": 0.16, "PreviousValue": 0.16, "Revenue": null, "RevenueValue": null, "RevenueForecast": null, "RevenueForecastValue": null, "RevenuePrevious": null, "RevenuePreviousValue": null, "MarketCapUSD": 560700000, "FiscalTag": "FY2017Q3", "FiscalReference": "Q3", "CalendarReference": "2016-12-31", "Country": "United States", "Currency": "USD", "Importance": 1, "Session": "after_close", "MarketRelease": "12/11/2022 7:05:00 PM", "LastUpdate": "12/11/2022 7:05:00 PM" } ``` ``` -------------------------------- ### Create HTTP Request for Country News in C# Source: https://docs.tradingeconomics.com/news/by-parameter Demonstrates the creation of an HTTP GET request message to fetch economic news for a specific country using C#. This focuses on setting up the request object with the API endpoint and API key. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/news/country/mexico?c=your_api_key"); ``` -------------------------------- ### Get Historical Financial Data (Python) Source: https://docs.tradingeconomics.com/financials/historical Retrieve historical financial data for a given symbol and category within a date range using Python. This example demonstrates fetching data using the 'requests' library and the Trading Economics package. Ensure you have the 'requests' library installed and replace 'YOUR_API_KEY' with your actual API key. ```python import requests api_key = 'YOUR_API_KEY' url = f'https://api.tradingeconomics.com/financials/historical/aapl:us:assets?d1=2022-01-01&d2=2023-01-01&c={api_key}' data = requests.get(url).json() print(data) ``` ```python te.getFinancialsHistorical(symbol = 'aapl:us', category = 'assets', initDate = '2022-01-01', endDate ='2023-01-01') ``` -------------------------------- ### Construct HTTP Request for News (C#) Source: https://docs.tradingeconomics.com/news/by-parameter Demonstrates the creation of an HTTP GET request message in C# to fetch news data for a specific country and indicator. This example focuses on constructing the request object, requiring manual handling of the API key and URL. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/news/country/mexico/inflation%20rate?c=your_api_key"); ``` -------------------------------- ### Fetch Financials by Category (C#) Source: https://docs.tradingeconomics.com/financials/snapshot Demonstrates fetching financial data by category using C# with `HttpClient`. This method requires an API key to be appended to the URL. The response content is read as a string and printed to the console. ```csharp using (var httpClient = new HttpClient()) { using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/financials/category/assets?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); } } } ``` -------------------------------- ### Create HTTP Request for Latest Updates in C# Source: https://docs.tradingeconomics.com/indicators/historical Constructs an HttpRequestMessage for fetching latest updates using C#. This example shows how to set up the request, including the URL and HTTP method. It uses a default guest API key. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/historical/updates?c=guest:guest"); ``` -------------------------------- ### Get News by Country/Indicator/Date (C# - HttpRequestMessage) Source: https://docs.tradingeconomics.com/news/by-parameter Constructs an HTTP GET request for retrieving news articles using C#. This example focuses on setting up the request message with the correct URL and HTTP method. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/news/country/mexico/inflation%20rate?c=your_api_key&d1=2021-02-02&d2=2021-03-03"); ``` -------------------------------- ### Initialize HTTP Request for Currency Cross Data in C# Source: https://docs.tradingeconomics.com/markets/snapshot Demonstrates the initialization of an HTTP GET request message in C# to fetch currency cross data for EUR from the Trading Economics API. This is a foundational step before sending the request and handling the response. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/markets/currency?c=your_api_key&cross=EUR"); ``` -------------------------------- ### Get News by Country/Indicator/Date (JavaScript - Axios) Source: https://docs.tradingeconomics.com/news/by-parameter Fetches news articles using JavaScript with the 'axios' library. This asynchronous example demonstrates how to make a GET request to the TradingEconomics API and log the response data. ```javascript const axios = require('axios'); (async () => { const api_key = 'YOUR_API_KEY' const response = await axios.get(`https://api.tradingeconomics.com/news/country/mexico/inflation%20rate?c=${api_key}&d1=2021-02-02&d2=2021-03-03`) console.log(response.data) })() ``` -------------------------------- ### Fetch Eurostat Data by Country/Category (C#) Source: https://docs.tradingeconomics.com/eurostat/snapshot Shows a C# example for fetching Eurostat data by country and category group. This snippet utilizes the `HttpRequestMessage` class to construct and send a GET request to the Trading Economics API. It assumes the availability of an API key and an appropriate HTTP client setup within the C# environment. The response handling (e.g., deserialization) would typically follow this request initiation. ```csharp using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/eurostat/country/Denmark?category_group=Interest%20rates&c=your_api_key")) ``` -------------------------------- ### Construct HTTP Request for Calendar Data (C#) Source: https://docs.tradingeconomics.com/economic_calendar/snapshot Demonstrates constructing an HTTP GET request message in C# to fetch calendar data from the Trading Economics API. This example shows how to set up the request URI, including authentication credentials. ```csharp new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/calendar/country/All/2016-12-02/2016-12-03?c=guest:guest"); ``` -------------------------------- ### Fetch Inflation Rate Data with JavaScript using Axios Source: https://docs.tradingeconomics.com/economic_calendar/indicator This snippet illustrates how to get inflation rate data from the Trading Economics API using Node.js and the `axios` library. It involves an asynchronous function, an API key, and a GET request to the API endpoint. The response data is then logged to the console. Ensure `axios` is installed (`npm install axios`). ```javascript const axios = require('axios'); (async () => { const api_key = 'YOUR_API_KEY' const response = await axios.get(`https://api.tradingeconomics.com/calendar/indicator/inflation%20rate?c=${api_key}`) console.log(response.data) })() ```