robinhood-csharp
1.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package robinhood-csharp --version 1.1.0
NuGet\Install-Package robinhood-csharp -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="robinhood-csharp" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add robinhood-csharp --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: robinhood-csharp, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install robinhood-csharp as a Cake Addin #addin nuget:?package=robinhood-csharp&version=1.1.0 // Install robinhood-csharp as a Cake Tool #tool nuget:?package=robinhood-csharp&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Introduction
C# library to make trades with Unofficial Robinhood API. <br> See @Sanko's Unofficial Documentation for more information.
Getting Started
- Install the package from GitHub packages or NuGet packages
dotnet add package robinhood-csharp
- Create Authentication section configuration in your project that call this package
"Authentication": {
//email
"UserName": "**********",
"Password": "**********",
"ClientId": "**********",
"ExpirationTime": 734000,
"Timeout": 5,
"ChallengeType": "sms"
}
Add the configuration needed for the package in
Program.cs
- REST API
builder.Services.ConfigureRb(builder.Configuration)
- Console APP
private static IConfiguration _configuration; private static IServiceProvider _serviceProvider; private static IHostBuilder CreateHostBuilder(string[] args) { return Host.CreateDefaultBuilder(args) .ConfigureHostConfiguration(AddConfiguration) .ConfigureServices(services => { services.ConfigureRb(_configuration); _serviceProvider = services.BuildServiceProvider(); }); } private static void AddConfiguration(IConfigurationBuilder builder) { IConfigurationBuilder configurationBuilder = builder .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", false, true); _configuration = configurationBuilder.Build(); }
- REST API
Inject
IRobinhood
InterfaceCall login method
AuthenticationResponse authResponse = await _robinhood.LoginAsync();
- Manage challenge case
if (authResponse.IsChallenge)
{
do
{
Challenge challenge = authResponse.Challenge;
Console.WriteLine($"Input challenge code from {challenge.Type} ({challenge.RemainingAttempts}/{challenge.RemainingRetries}):");
string code = Console.ReadLine();
authResponse = await _robinhood.ChallengeOauth2Async(challenge.Id, code);
} while (authResponse.IsChallenge && authResponse.Challenge.CanRetry);
}
- Manage Mfa case
if (authResponse.MfaRequired)
{
int attempts = 3;
(HttpStatusCode statusCode, AuthenticationResponse mfaAuth) mfaResponse;
do
{
Console.WriteLine($"Input the MFA code:");
string code = Console.ReadLine();
mfaResponse = await _robinhood.MfaOath2Async(code);
attempts--;
} while (attempts > 0 && mfaResponse.statusCode != HttpStatusCode.OK);
authResponse = mfaResponse.mfaAuth;
}
- Configure the token expiration date, refresh token and Authorization header by calling ConfigureManager method
_robinhood.ConfigureManager(authResponse);
Samples and tests
- Check user information example :
User user = await _robinhood.GetUserAsync();
- Find tests examples for all routes under samples/RbConsoleApp project.
- Find one test example for REST API under samples/RbWebApi project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.WebUtilities (>= 8.0.7)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
- System.Text.Json (>= 8.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.