This is an unofficial SDK for using the Turso Platform API in C#. It supports all available v1 endpoints.
Complete setup information can be found in the Turso quickstart guide.
- First install the Turso CLI.
- Use the CLI to get your account user or organization slug.
turso org list - Create a platform API token.
turso auth api-tokens mint quickstart
Install the package in your project.
dotnet add package rthomasv3.TursoPlatformApi
The services and methods are a one-to-one mapping with the Turso documentation.
For example, to list all databases:
await tursoPlatformService.Databases.List();| Service | Usage |
|---|---|
| ITursoPlatformService | The overall platform service with properties for all other services. |
| ITursoDatabaseService | Manage databases. |
| ITursoGroupService | Manage groups. |
| ITursoLocationService | View locations. |
| ITursoOrganizationsService | Manage organizations. |
| ITursoMembersService | Manage members. |
| ITursoInvitesService | Manage invites. |
| ITursoAuditLogsService | View audit logs. |
| ITursoApiTokensService | Manage platform API tokens. |
The easiest way to use the Turso Platform API Service is using dependency injection.
Add a TursoPlatformApi section to your appsettings.json file. Use appsettings.Development.json to avoid keys ending up in your repo.
{
"TursoPlatformApi": {
"DefaultOrganizationSlug": "<your-organization-slug>",
"AuthToken": "<your-api-token>"
}
}After that you can add Turso Platform API Service using the provided services extension method. If you prefer, you can pass in your org slug and API key to the AddTursoPlatformService method instead of using appsettings.json.
builder.Services.AddTursoPlatformService();Then you can add any of the API services to the constructors in your application.
You can also create and use an instance directly if you prefer.
// create a new instance
var tursoPlatformApi = new TursoPlatformApi.TursoPlatformService("<your-organization-slug>", "<your-api-token>");
var allGroups = await tursoPlatformApi.Groups.List();or
// static instance
TursoPlatformApi.TursoPlatformService.Initialize("<your-organization-slug>", "<your-api-token>");
var allDatabases = await TursoPlatformApi.TursoPlatformService.Instance.Databases.List();