scott oliver

scott oliver

  • NA
  • 82
  • 14.8k

Pull API data with RestSharp and insert into SQLite

Oct 7 2020 6:53 PM
Hello, I want to take some information from the OTC website API and put it into a sqlite db. This is what I have to pull the information. It currently saves it into a csv file. What is the easiest way to write it to the DB instead?
  1. public void otcRestClient()  
  2. {  
  3.     var restSharpClient = new RestClient("https://www.otcmarkets.com");  
  4.   
  5.     var downloadRequest = new RestRequest("research/stock-screener/api/downloadCSV?pageSize=20",  
  6.         Method.GET);  
  7.   
  8.     var fileInBytes = restSharpClient.DownloadData(downloadRequest);  
  9.   
  10.     File.WriteAllBytes(@"C:\Users\openuser\Documents\Stock Reports\OTC\OTCStockData.csv",  
  11.         fileInBytes);  
  12.   
  13.     Console.WriteLine("\n\nPress any key ...");  
  14.     Console.ReadKey();  
  15. }

Answers (2)