SpeakeasySDK 5.11.0
dotnet add package SpeakeasySDK --version 5.11.0
NuGet\Install-Package SpeakeasySDK -Version 5.11.0
<PackageReference Include="SpeakeasySDK" Version="5.11.0" />
paket add SpeakeasySDK --version 5.11.0
#r "nuget: SpeakeasySDK, 5.11.0"
// Install SpeakeasySDK as a Cake Addin #addin nuget:?package=SpeakeasySDK&version=5.11.0 // Install SpeakeasySDK as a Cake Tool #tool nuget:?package=SpeakeasySDK&version=5.11.0
SpeakeasySDK
SDK Example Usage
Example
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
Authentication
Per-Client Security Schemes
This SDK supports the following security schemes globally:
Name | Type | Scheme |
---|---|---|
APIKey |
apiKey | API key |
Bearer |
http | HTTP Bearer |
WorkspaceIdentifier |
apiKey | API key |
You can set the security parameters through the security
optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
Global Parameters
A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.
For example, you can set workspace_id
to "<id>"
at SDK initialization and then you do not have to pass the same value on calls to operations like GetAccessToken
. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
Available Globals
The following global parameter is available.
Name | Type | Description |
---|---|---|
workspaceId | string | The WorkspaceId parameter. |
Example
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
var sdk = new SDK();
GetAccessTokenRequest req = new GetAccessTokenRequest() {
WorkspaceId = "<id>",
};
var res = await sdk.Auth.GetAccessTokenAsync(req);
// handle response
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply pass a RetryConfig
to the call:
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {};
var res = await sdk.Auth.GetAccessAsync(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
request: req
);
// handle response
If you'd like to override the default retry strategy for all operations that support retries, you can use the RetryConfig
optional parameter when intitializing the SDK:
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
}
);
GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {};
var res = await sdk.Auth.GetAccessAsync(req);
// handle response
Error Handling
Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.
By default, an API error will raise a SpeakeasySDK.Models.Errors.SDKException
exception, which has the following properties:
Property | Type | Description |
---|---|---|
Message |
string | The error message |
StatusCode |
int | The HTTP status code |
RawResponse |
HttpResponseMessage | The raw HTTP response |
Body |
string | The response content |
When custom error responses are specified for an operation, the SDK may also throw their associated exceptions. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the GenerateCodeSamplePreviewAsync
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
SpeakeasySDK.Models.Errors.Error | 4XX, 5XX | application/json |
Example
using SpeakeasySDK;
using SpeakeasySDK.Models.Errors;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
try
{
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
}
catch (Exception ex)
{
if (ex is Error)
{
// Handle exception data
throw;
}
else if (ex is SpeakeasySDK.Models.Errors.SDKException)
{
// Handle default exception
throw;
}
}
Server Selection
Select Server by Name
You can override the default server globally by passing a server name to the server: string
optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
Name | Server |
---|---|
prod |
https://api.prod.speakeasyapi.dev |
Example
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(
server: "prod",
security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
}
);
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the serverUrl: string
optional parameter when initializing the SDK client instance. For example:
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(
serverUrl: "https://api.prod.speakeasyapi.dev",
security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
}
);
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- newtonsoft.json (>= 13.0.3)
- nodatime (>= 3.1.9)
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 |
---|---|---|
5.11.0 | 101 | 1/2/2025 |
5.10.0 | 113 | 9/20/2024 |
5.9.28 | 88 | 9/19/2024 |
5.9.27 | 80 | 7/31/2024 |
5.9.25 | 99 | 7/18/2024 |
5.9.23 | 103 | 7/17/2024 |
5.9.22 | 102 | 7/17/2024 |
5.9.21 | 101 | 7/17/2024 |
5.9.18 | 104 | 7/16/2024 |
5.9.17 | 105 | 7/2/2024 |
5.9.16 | 121 | 6/20/2024 |
5.9.15 | 117 | 6/20/2024 |
5.9.14 | 116 | 6/20/2024 |
5.9.10 | 114 | 6/18/2024 |
5.9.9 | 108 | 6/11/2024 |
5.9.8 | 109 | 6/11/2024 |
5.3.0 | 125 | 4/2/2024 |
5.2.0 | 130 | 3/27/2024 |
5.1.2 | 128 | 3/22/2024 |
5.1.1 | 134 | 3/20/2024 |
5.1.0 | 138 | 3/12/2024 |
5.0.3 | 122 | 2/17/2024 |
5.0.2 | 125 | 2/15/2024 |
5.0.1 | 136 | 2/9/2024 |
5.0.0 | 125 | 2/8/2024 |
4.0.0 | 140 | 2/6/2024 |
3.0.0 | 122 | 2/1/2024 |
2.3.1 | 118 | 1/19/2024 |
2.3.0 | 166 | 12/12/2023 |
2.2.2 | 160 | 12/1/2023 |
2.2.1 | 163 | 11/18/2023 |
2.2.0 | 140 | 11/16/2023 |
2.1.0 | 144 | 11/9/2023 |
2.0.0 | 126 | 11/7/2023 |
1.17.0 | 169 | 10/21/2023 |
1.16.4 | 163 | 10/18/2023 |
1.16.3 | 159 | 10/17/2023 |
1.16.2 | 170 | 10/7/2023 |
1.16.1 | 167 | 10/2/2023 |
1.16.0 | 157 | 10/1/2023 |
1.15.0 | 144 | 9/29/2023 |
1.14.1 | 162 | 9/27/2023 |
1.14.0 | 159 | 9/26/2023 |
1.13.7 | 157 | 9/20/2023 |
1.13.6 | 152 | 9/16/2023 |
1.13.5 | 147 | 9/8/2023 |
1.13.4 | 167 | 9/7/2023 |
1.13.3 | 179 | 9/5/2023 |
1.13.2 | 172 | 9/3/2023 |
1.13.1 | 181 | 9/2/2023 |
1.13.0 | 172 | 9/1/2023 |
1.12.0 | 178 | 8/31/2023 |
1.11.0 | 177 | 8/26/2023 |
1.10.1 | 174 | 8/25/2023 |
1.10.0 | 184 | 8/15/2023 |
1.9.0 | 206 | 8/8/2023 |
1.8.0 | 201 | 8/4/2023 |
1.7.0 | 198 | 8/3/2023 |
1.6.1 | 198 | 8/1/2023 |
1.6.0 | 176 | 7/28/2023 |
1.5.1 | 201 | 7/27/2023 |
1.5.0 | 197 | 7/26/2023 |
1.4.0 | 216 | 7/22/2023 |
1.3.1 | 198 | 7/19/2023 |
1.3.0 | 212 | 7/18/2023 |
1.2.0 | 202 | 7/14/2023 |
1.1.0 | 207 | 7/13/2023 |
1.0.6 | 204 | 7/12/2023 |
1.0.5 | 191 | 7/11/2023 |
1.0.4 | 203 | 7/11/2023 |
1.0.3 | 210 | 7/11/2023 |