robinhood-csharp 1.0.6

Additional Details

upgrade to 1.0.7 because this version use system.text.json 8.0.3 that have a security bug

There is a newer version of this package available.
See the version list below for details.
dotnet add package robinhood-csharp --version 1.0.6                
NuGet\Install-Package robinhood-csharp -Version 1.0.6                
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.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add robinhood-csharp --version 1.0.6                
#r "nuget: robinhood-csharp, 1.0.6"                
#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.0.6

// Install robinhood-csharp as a Cake Tool
#tool nuget:?package=robinhood-csharp&version=1.0.6                

Introduction

C# library to make trades with Unofficial Robinhood API.

See @Sanko's Unofficial Documentation for more information.

Getting Started

  1. Install the package
  2. Create Authentication section configuration in your project that call this package
"Authentication": {
    "UserName": "**********",
    "Password": "**********",
    "ClientId": "**********",
    "ExpirationTime": 734000,
    "Timeout": 5,
    "ChallengeType": "sms"
  }
  1. Inject IRobinhood Interface and Robinhood class in Program.Cs, example for Console App :
IRobinhood _robinhood = _serviceProvider.GetRequiredService<IRobinhood>(); 
  1. Call login method and manage responses types
AuthenticationResponse authResponse = await _robinhood.LoginAsync();

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);
}

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;
}

if (!authResponse.IsOauthValid)
{
	string message;
	if (!string.IsNullOrEmpty(authResponse.Error))
	{
		message = authResponse.Error;
	}
	else
	{
		message = !string.IsNullOrEmpty(authResponse.Detail) ? authResponse.Detail : "Unknown login error";
	}

	Console.WriteLine(message);
	throw new AuthenticationException(message);
}
  1. 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 tests/RbConsoleApp project.

Source code

GitHub Repository https://github.com/sajidmohammed88/robinhood-csharp

Product 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 108 10/9/2024
1.1.0 87 7/27/2024
1.0.7 104 7/20/2024
1.0.6 150 5/28/2024 1.0.6 is deprecated because it has critical bugs.