Api to find company's info based on its publicly traded stock symbol. IEX Trading api is a best an reliable, alternative to Yahoo Finance and Google Finance Api.
Consuming Company's Info IEX Trading api using Postman:
Web Api Url: https://api.iextrading.com/1.0/stock/aapl/company
Api Response:
{ "symbol": "AAPL", "companyName": "Apple Inc.", "exchange": "Nasdaq Global Select", "industry": "Computer Hardware", "website": "http://www.apple.com", "description": "Apple Inc is an American multinational technology company. It designs, manufactures, and markets mobile communication and media devices, personal computers, and portable digital music players.", "CEO": "Timothy D. Cook", "issueType": "cs", "sector": "Technology", }
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 CompanyInfoResponse { public string symbol { get; set; } public string companyName { get; set; } public string exchange { get; set; } public string industry { get; set; } public string website { get; set; } public string description { get; set; } public string CEO { get; set; } public string issueType { get; set; } public string sector { 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 CompaniesInfo { class Program { static void Main(string[] args) { var symbol = "msft"; var IEXTrading_API_PATH = "https://api.iextrading.com/1.0/stock/{0}/company"; 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 companysInfo = response.Content.ReadAsAsync<CompanyInfoResponse>().GetAwaiter().GetResult(); if (companysInfo != null) { Console.WriteLine("Company Name: " + companysInfo.companyName); Console.WriteLine("Industry: " + companysInfo.industry); Console.WriteLine("Sector: " + companysInfo.sector); Console.WriteLine("Website: " + companysInfo.website); } } } } } public class CompanyInfoResponse { public string symbol { get; set; } public string companyName { get; set; } public string exchange { get; set; } public string industry { get; set; } public string website { get; set; } public string description { get; set; } public string CEO { get; set; } public string issueType { get; set; } public string sector { 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.