Api to find stock's Earnings info based on its publicly traded stock symbol. Pulls data from the four most recent reported quarters. IEX Trading api is a best an reliable, alternative to Yahoo Finance and Google Finance Api.
Api for Stock's Earnings Info - IEX Trading api using Postman:
Web Api Url: https://api.iextrading.com/1.0/stock/msft/earnings
Api Response:
{ symbol: "MSFT", earnings: [ { actualEPS: 0.98, consensusEPS: 0.71, estimatedEPS: 0.71, announceTime: "AMC", numberOfEstimates: 14, EPSSurpriseDollar: 0.27, EPSReportDate: "2017-07-20", fiscalPeriod: "Q4 2017", fiscalEndDate: "2017-06-30" }, { actualEPS: 0.73, consensusEPS: 0.69, estimatedEPS: 0.69, announceTime: "AMC", numberOfEstimates: 15, EPSSurpriseDollar: 0.04, EPSReportDate: "2017-04-27", fiscalPeriod: "Q3 2017", fiscalEndDate: "2017-03-31" }, { actualEPS: 0.83, consensusEPS: 0.79, estimatedEPS: 0.79, announceTime: "AMC", numberOfEstimates: 16, EPSSurpriseDollar: 0.04, EPSReportDate: "2017-01-26", fiscalPeriod: "Q2 2017", fiscalEndDate: "2016-12-31" }, { actualEPS: 0.76, consensusEPS: 0.68, estimatedEPS: 0.68, announceTime: "AMC", numberOfEstimates: 15, EPSSurpriseDollar: 0.08, EPSReportDate: "2016-10-20", fiscalPeriod: "Q1 2017", fiscalEndDate: "2016-09-30" } ] }
Create a console application
Add following nuget packages
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" /> <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" /> </packages>
Create a C# POCO class for storing Json Response.
public class Earning { public double actualEPS { get; set; } public double consensusEPS { get; set; } public double estimatedEPS { get; set; } public string announceTime { get; set; } public int numberOfEstimates { get; set; } public double EPSSurpriseDollar { get; set; } public string EPSReportDate { get; set; } public string fiscalPeriod { get; set; } public string fiscalEndDate { get; set; } } public class EarningsInfo { public string symbol { get; set; } public List<Earning> earnings { get; set; } }
Write Web API Consumer for Get Request
using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; namespace EarningsInfo { class Program { static void Main(string[] args) { var symbol = "msft"; var IEXTrading_API_PATH = "https://api.iextrading.com/1.0/stock/{0}/financials"; IEXTrading_API_PATH = string.Format(IEXTrading_API_PATH, symbol); using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); //For IP-API client.BaseAddress = new Uri(IEXTrading_API_PATH); HttpResponseMessage response = client.GetAsync(IEXTrading_API_PATH).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { var earningsInfoList = response.Content.ReadAsAsync<EarningsInfo>().GetAwaiter().GetResult(); foreach (var earningsInfo in earningsInfoList.earnings) { if (earningsInfo != null) { Console.WriteLine("Actual EPS: " + earningsInfo.actualEPS); Console.WriteLine("Estimated EPS: " + earningsInfo.estimatedEPS); Console.WriteLine("EPS Surprise Dollar: " + earningsInfo.EPSSurpriseDollar); Console.WriteLine("EPS Report Date: " + earningsInfo.EPSReportDate); Console.WriteLine("Fiscal Period: " + earningsInfo.fiscalPeriod); } } } } } } public class Earning { public double actualEPS { get; set; } public double consensusEPS { get; set; } public double estimatedEPS { get; set; } public string announceTime { get; set; } public int numberOfEstimates { get; set; } public double EPSSurpriseDollar { get; set; } public string EPSReportDate { get; set; } public string fiscalPeriod { get; set; } public string fiscalEndDate { get; set; } } public class EarningsInfo { public string symbol { get; set; } public List<Earning> earnings { get; set; } } }
Note: IEX Trading is 100% Free and reliable api to get stock market data. The free API is built on a proven, high-performance system, and drives many of the applications we use within IEX. Usage of IEX Trading api - 100 requests per second.