A .NET library (netstandard2.1) for accessing local Blink camera storage: fetching the list of clips, downloading and deleting videos. Works on runtimes that support .NET Standard 2.1 (for example .NET 6/7/8/9, .NET Core 3.0+).
- Login/password authorization and PIN confirmation (2FA).
- Fetching dashboard data and the list of Sync Modules.
- Getting the list of clips from a module's local storage.
- Download a clip as a byte array.
- Delete a clip from the device.
- Configurable delay between requests to stabilize the API.
Via .NET CLI:
dotnet add package Blink.NETVia PackageReference:
<ItemGroup>
<PackageReference Include="Blink.NET" Version="x.y.z" />
<!-- see the latest version on https://www.nuget.org/packages/Blink.NET/ -->
</ItemGroup>Simple scenario: login, complete 2FA, then download clips from a single Sync Module.
using Blink;
var client = new BlinkClient();
// 1) Login with email/password
bool okLogin = await client.TryLoginAsync("[email protected]", "YourPassword");
if (!okLogin)
{
throw new Exception("Wrong email or password");
}
// 2) Enter and verify 2FA code
Console.Write("Enter 2FA code: ");
var code = Console.ReadLine() ?? string.Empty;
bool ok2FA = await client.TryVerifyPinAsync(code);
if (!ok2FA)
{
throw new Exception("Invalid 2FA code");
}
// 3) Get clips from a single Sync Module (throws if more than one module exists)
var videos = await client.GetVideosFromSingleModuleAsync();
// 4) Download the first clip as bytes
var first = videos.First();
byte[] bytes = await client.GetVideoBytesAsync(first);
File.WriteAllBytes($"{first.Id}.mp4", bytes);Use a two-stage flow: first login with email/password and complete 2FA to obtain a refresh token; then reuse the refresh token on subsequent runs to skip 2FA.
using Serilog;
using Blink;
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console()
.CreateLogger();
var client = new BlinkClient();
// 1) First-time login + 2FA to get refresh token
bool okLogin = await client.TryLoginAsync(email, password);
if (!okLogin)
{
Log.Error("Wrong email or password");
return;
}
Log.Information("Enter 2FA code:");
while (true)
{
string code = Console.ReadLine() ?? string.Empty;
if (string.IsNullOrWhiteSpace(code))
{
Log.Warning("Code cannot be empty. Please enter the 2FA code:");
continue;
}
bool ok2FA = await client.TryVerifyPinAsync(code);
if (ok2FA)
{
Log.Information("2FA verification successful.");
break;
}
Log.Error("Invalid 2FA code. Please try again:");
}
Log.Information("Save this refresh token for future use: {RefreshToken}", client.RefreshToken);
// 2) Subsequent runs — login with refresh token
bool okRefresh = await client.TryLoginWithRefreshTokenAsync(refreshTokenFromStore);
if (!okRefresh)
{
Log.Error("Failed to refresh token");
return;
}
var dashboard = await client.GetDashboardAsync();
Log.Information("Dashboard retrieved. Modules count: {Count}", dashboard.SyncModules.Length);- Login and, if necessary, PIN confirmation:
bool okLogin = await client.TryLoginAsync(email, password);
if (!okLogin)
{
// invalid credentials
return;
}
bool ok2FA = await client.TryVerifyPinAsync(pinFromSms);
if (!ok2FA)
{
// invalid/expired code
return;
}- Get Sync Modules and clips:
var dashboard = await client.GetDashboardAsync();
var module = dashboard.SyncModules.Single(); // choose the desired module
var videos = await client.GetVideosFromModuleAsync(module);- Download a clip and (optionally) delete it:
var data = await client.GetVideoBytesAsync(video);
await File.WriteAllBytesAsync($"{video.Id}.mp4", data);
// if needed — delete the clip from the device
// await client.DeleteVideoAsync(video);- GeneralSleepTime (int, default 3500 ms) Small delay between requests. Without it the server may sometimes return an empty response. You can reduce or disable it if your environment is stable. For background jobs, consider higher values (e.g., 5–10 seconds) to improve reliability.
Token handling:
- RefreshToken (string?) — populated after successful 2FA. Store it securely and use
TryLoginWithRefreshTokenAsyncto skip 2FA on subsequent runs.
- Task GetDashboardAsync()
- Task<IEnumerable> GetVideosFromModuleAsync(SyncModule module)
- Task<IEnumerable> GetVideosFromSingleModuleAsync()
- Task<byte[]> GetVideoBytesAsync(BlinkVideoInfo video, int tryCount = 3)
- Task DeleteVideoAsync(BlinkVideoInfo video)
Login/token flows:
- Task TryLoginAsync(string email, string password)
- Task TryVerifyPinAsync(string code)
- Task TryLoginWithRefreshTokenAsync(string refreshToken)
- string? RefreshToken { get; }
Events:
- event Action? OnTokenRefreshed — raised whenever a new refresh token is issued (after successful 2FA or token refresh). Subscribe to persist it:
var client = new BlinkClient();
client.OnTokenRefreshed += token => SaveRefreshToken(token);See models and exceptions in Sources/Blink/Models and Sources/Blink/Exceptions.
There is a small example in Sources/Blink.ConsoleTest:
- Create a
secrets.jsonfile next toProgram.cswith your login/password:
{
"email": "[email protected]",
"password": "YourPassword"
}- Build and run:
cd Sources/Blink.ConsoleTest
dotnet build
dotnet run- A Blink account and at least one Sync Module with local storage are required.
- Client verification (PIN via SMS) is often enabled. This is normal behavior.
- The Blink API can be unstable without pauses between requests — use
GeneralSleepTime.
Note on clip IDs (observed behavior):
- The IDs returned in the video list appear to be short‑lived session identifiers. In practice, fetching the binary clip by a previously listed ID may start failing with “file not found” after a short time window (approx. 10–20 minutes, based on observations; not officially documented).
- Recommendation: process videos in small batches. Fetch a list, immediately download a subset, then re‑list before continuing to avoid stale IDs.
- Do not store login/password in the repository. Use user secrets, environment variables, or encrypted stores.
- Remove tokens and personal data from logs before publishing.
dotnet build Sources/Blink/Blink.csprojThis project is not affiliated with Blink, Amazon, or any other companies. Use at your own risk and in accordance with Blink's terms of service.
MIT — see LICENSE.md.