C# SDK
C# / .NET Quick Start
WoWSQL C# SDK — Get started in minutes
Get your API key: Use the WoWSQL project dashboard to create or copy your API key. The same key works for database, auth, and storage (unified API key).
Installation
Official package: View on NuGet →
.NET CLI:
dotnet add package WowSQL.SDK
Package Manager Console:
Install-Package WOWSQL.SDK
PackageReference (csproj):
<PackageReference Include="WOWSQL.SDK" Version="1.0.0" />
Initialize Client
using WowSQL;
// Initialize client with your API key (same key for database, auth, storage)
var client = new WowSQLClient(
projectUrl: "myproject",
apiKey: "your_api_key_here"
);
// Or with full URL
var clientFull = new WowSQLClient(
projectUrl: "https://myproject.wowsql.com",
apiKey: "your_api_key"
);
// Always use Select() before GetAsync()/ExecuteAsync()
var users = await client.Table("users").Select("*").GetAsync();
Query Data
Basic Queries
// Get all records
var users = await client.Table("users").Select("*").GetAsync();
// With filters
var adults = await client.Table("users").Select("*").Gte("age", 18).GetAsync();
// Select specific columns
var names = await client.Table("users").Select("id", "name").GetAsync();
Advanced Queries
// Multiple filters with sorting
var activeUsers = await client.Table("users")
.Select("*")
.Eq("status", "active")
.Gt("age", 18)
.Order("created_at", "desc")
.Limit(20)
.Offset(0)
.GetAsync();
Console.WriteLine($"Found {activeUsers.Count} users");
foreach (var user in activeUsers.Data)
Console.WriteLine(user["name"]);
Filter Helper Methods
// Using helper methods: Eq, Gt, Like, In, Between
var users = await client.Table("users")
.Eq("status", "active")
.Gt("age", 18)
.Like("email", "%@gmail.com")
.In("role", new[] { "admin", "moderator" })
.Between("created_at", "2024-01-01", "2024-12-31")
.GetAsync();
GROUP BY and Aggregates
Basic GROUP BY
var result = await client.Table("products")
.Select("category", "COUNT(*) as count", "AVG(price) as avg_price")
.GroupBy("category")
.GetAsync();
var result2 = await client.Table("orders")
.Select("DATE(created_at) as date", "COUNT(*) as orders", "SUM(total) as revenue")
.GroupBy("DATE(created_at)")
.OrderBy("date", "desc")
.GetAsync();
HAVING Clause
var result = await client.Table("products")
.Select("category", "COUNT(*) as count")
.GroupBy("category")
.Having("COUNT(*)", "gt", 10)
.GetAsync();
CRUD Operations
Create Record
var result = await client.Table("users").CreateAsync(new Dictionary<string, object>
{
["name"] = "John Doe",
["email"] = "john@example.com",
["age"] = 30
});
Console.WriteLine($"Created user with ID: {result["id"]}");
Update Record
await client.Table("users").UpdateAsync(123, new Dictionary<string, object>
{
["email"] = "newemail@example.com"
});
Console.WriteLine("User updated successfully");
Delete Record
await client.Table("users").DeleteAsync(123);
Console.WriteLine("User deleted successfully");
Get Single Record by ID
var user = await client.Table("users").GetByIdAsync(123);
Console.WriteLine($"User: {user["name"]}");
Get First Record
var user = await client.Table("users").Eq("status", "active").FirstAsync();
if (user != null) Console.WriteLine($"First active user: {user["name"]}");
Filter Operators
Available operators: eq, neq, gt, gte, lt, lte, like, is, in, not_in, between, not_between. Use .Eq("col", value), .Filter("col", "op", value), etc.
Error Handling
try
{
var users = await client.Table("users").Select("*").GetAsync();
Console.WriteLine($"Success: {users.Data.Count} users");
}
catch (WOWSQLException e)
{
if (e.StatusCode == 401) Console.WriteLine("Authentication failed — check your API key");
else if (e.StatusCode == 404) Console.WriteLine("Table or resource not found");
else Console.WriteLine($"Error ({e.StatusCode}): {e.Message}");
}
finally { client.Dispose(); }
Automatic Disposal
// Using statement ensures proper disposal
using (var client = new WowSQLClient("myproject", "your-api-key"))
{
var users = await client.Table("users").GetAsync();
// Client is automatically disposed when exiting the using block
}
using (var storage = new WowSQLStorage("myproject", "your-api-key"))
{
var quota = await storage.GetQuotaAsync();
// Storage is automatically disposed
}
Authentication
Use the same API key for authentication. One key works for database and auth.
Sign Up & Sign In
var auth = new WowSQLAuth(projectUrl: "myproject", apiKey: "your_api_key");
var result = await auth.SignUpAsync("user@example.com", "SecurePassword123", "John Doe");
Console.WriteLine($"Access token: {result["access_token"]}");
var login = await auth.SignInAsync("user@example.com", "SecurePassword123");
Console.WriteLine($"User ID: {login["user"]["id"]}");
Password Reset
await auth.ForgotPasswordAsync("user@example.com");
await auth.ResetPasswordAsync("reset_token_from_email", "NewSecurePassword123");
Storage Operations
Initialize Storage
var storage = new WowSQLStorage(
projectUrl: "myproject",
apiKey: "your_api_key"
);
File Operations
// Upload file
var result = await storage.UploadFromPathAsync("path/to/document.pdf", "uploads/document.pdf", "documents");
Console.WriteLine($"Uploaded: {result["file_key"]}");
// Get file URL
var urlData = await storage.GetFileUrlAsync("uploads/document.pdf", 3600);
Console.WriteLine($"Download URL: {urlData["file_url"]}");
// List files
var files = await storage.ListFilesAsync("uploads/");
foreach (var file in files) Console.WriteLine($"{file.Key}: {file.SizeMb} MB");
// Delete file
await storage.DeleteFileAsync("uploads/document.pdf");
// Check quota
var quota = await storage.GetQuotaAsync();
Console.WriteLine($"Used: {quota.UsedGb} GB / {quota.QuotaGb} GB");
Download or View File
Via REST: use GET .../files/{file_key}/download for attachment download, or GET .../files/{file_key}/view to view inline in the browser.