public static void Main()
string code = @"using System;
public static void Main()
Console.WriteLine(Fibonacci(6));
public static int Fibonacci(int n)
return Fibonacci(n-1) + Fibonacci(n-2);
var ApiUrl = "https://dotnetfiddle.net/api/fiddles/";
var client = new RestClient(ApiUrl);
var request = new RestRequest("execute", Method.POST);
request.RequestFormat = DataFormat.Json;
var model = new FiddleExecuteModel()
Compiler = Compiler.Net45,
Language = Language.CSharp,
ProjectType = ProjectType.Console,
IRestResponse<FiddleExecuteResult> response = client.Execute<FiddleExecuteResult>(request);
StringBuilder result = new StringBuilder();
if (response.StatusCode != HttpStatusCode.OK)
result.AppendLine("Failed to execute API request. Here is an answer from API");
result.AppendLine("Response Code: " + response.StatusCode);
result.AppendLine("Response Body: " + response.Content);
foreach (var header in response.Headers)
if (header.Name == "X-RateLimit-Limit")
result.AppendLine("Your total per hour limit is " + header.Value);
if (header.Name == "X-RateLimit-Remaining")
result.AppendLine("Your remaining executions count per hour is " + header.Value);
if (header.Name == "X-RateLimit-Reset")
var epochTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
epochTime = epochTime.AddSeconds(int.Parse(header.Value.ToString()));
result.AppendLine("UTC Time when limit will be refreshed " + epochTime);
result.AppendLine("Code output:");
result.AppendLine(response.Data.ConsoleOutput);
Console.WriteLine(result.ToString());
public class FiddleExecuteModel
public Language Language { get; set; }
public ProjectType ProjectType { get; set; }
public Compiler Compiler { get; set; }
public string CodeBlock { get; set; }
public string[] ConsoleInputLines { get; set; }
public MvcCodeBlock MvcCodeBlock { get; set; }
public NuGetPackages[] NuGetPackages {get;set;}
public class MvcCodeBlock
public string Model { get; set; }
public string View { get; set; }
public string Controller { get; set; }
public class FiddleExecuteResult
public string ConsoleOutput { get; set; }
public RunStatsViewModel Stats { get; set; }
public string WebPageHtmlOutput { get; set; }
public bool IsConsoleInputRequested { get; set; }
public bool HasErrors { get; set; }
public bool HasCompilationErrors { get; set; }
public class NuGetPackages
public string NuGetId { get; set; }
public string VersionName { get; set; }
public class RunStatsViewModel
public string RunAt { get; set; }
public string CompileTime { get; set; }
public string ExecuteTime { get; set; }
public string MemoryUsage { get; set; }
public string CpuUsage { get; set; }