Speakeasy API: The Speakeasy API allows teams to manage common operations with their APIs
For more information about the API: The Speakeasy Platform Documentation
- SDK Installation
- SDK Example Usage
- Available Resources and Operations
- Global Parameters
- Retries
- Error Handling
- Server Selection
- Authentication
To add the NuGet package to a .NET project:
dotnet add package SpeakeasySDK
To add a reference to a local instance of the SDK in a .NET project:
dotnet add reference src/SpeakeasySDK/SpeakeasySDK.csproj
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using System.Collections.Generic;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
GetApisRequest req = new GetApisRequest() {};
var res = await sdk.Apis.GetApisAsync(req);
// handle response
Available methods
- DeleteApiEndpoint - Delete an ApiEndpoint.
- FindApiEndpoint - Find an ApiEndpoint via its displayName.
- GenerateOpenApiSpecForApiEndpoint - Generate an OpenAPI specification for a particular ApiEndpoint.
- GeneratePostmanCollectionForApiEndpoint - Generate a Postman collection for a particular ApiEndpoint.
- GetAllApiEndpoints - Get all Api endpoints for a particular apiID.
- GetAllForVersionApiEndpoints - Get all ApiEndpoints for a particular apiID and versionID.
- GetApiEndpoint - Get an ApiEndpoint.
- UpsertApiEndpoint - Upsert an ApiEndpoint.
- DeleteApi - Delete an Api.
- GenerateOpenApiSpec - Generate an OpenAPI specification for a particular Api.
- GeneratePostmanCollection - Generate a Postman collection for a particular Api.
- GetAllApiVersions - Get all Api versions for a particular ApiEndpoint.
- GetApis - Get a list of Apis for a given workspace
- UpsertApi - Upsert an Api
- GetBlob - Get blob for a particular digest
- GetManifest - Get manifest for a particular reference
- GetNamespaces - Each namespace contains many revisions.
- GetOASSummary
- GetRevisions
- GetTags
- PostTags - Add tags to an existing revision
- Preflight - Get access token for communicating with OCI distribution endpoints
- GetAccessToken - Get or refresh an access token for the current workspace.
- GetUser - Get information about the current user.
- GetWorkspaceAccess - Get access allowances for a particular workspace
- ValidateApiKey - Validate the current api key.
- GetEmbedAccessToken - Get an embed access token for the current workspace.
- GetValidEmbedAccessTokens - Get all valid embed access tokens for the current workspace.
- RevokeEmbedAccessToken - Revoke an embed access EmbedToken.
- GetWorkspaceEventsByTarget - Load recent events for a particular workspace
- GetWorkspaceTargets - Load targets for a particular workspace
- PostWorkspaceEvents - Post events for a specific workspace
- SearchWorkspaceEvents - Search events for a particular workspace by any field
- CheckAccess
- ConfigureCodeSamples
- ConfigureMintlifyRepo
- ConfigureTarget
- FetchPublishingPRs
- GetAction
- GithubCheckPublishingSecrets
- GithubStorePublishingSecrets
- TriggerAction
- DeleteVersionMetadata - Delete metadata for a particular apiID and versionID.
- GetVersionMetadata - Get all metadata for a particular apiID and versionID.
- InsertVersionMetadata - Insert metadata for a particular apiID and versionID.
- CreateFreeTrial - Create a free trial for an organization
- GetOrganization - Get organization
- GetOrganizationUsage - Get billing usage summary for a particular organization
- GetOrganizations - Get organizations for a user
- GetChangesReportSignedUrl - Get the signed access url for the change reports for a particular document.
- GetLintingReportSignedUrl - Get the signed access url for the linting reports for a particular document.
- UploadReport - Upload a report.
- GenerateRequestPostmanCollection - Generate a Postman collection for a particular request.
- GetRequestFromEventLog - Get information about a particular request.
- QueryEventLog - Query the event log to retrieve a list of requests.
- DeleteSchema - Delete a particular schema revision for an Api.
- DownloadSchema - Download the latest schema for a particular apiID.
- DownloadSchemaRevision - Download a particular schema revision for an Api.
- GetSchema - Get information about the latest schema.
- GetSchemaDiff - Get a diff of two schema revisions for an Api.
- GetSchemaRevision - Get information about a particular schema revision for an Api.
- GetSchemas - Get information about all schemas associated with a particular apiID.
- RegisterSchema - Register a schema.
- Create - Shorten a URL.
- Suggest - Generate suggestions for improving an OpenAPI document.
- SuggestOpenAPI - (DEPRECATED) Generate suggestions for improving an OpenAPI document.
- SuggestOpenAPIRegistry - Generate suggestions for improving an OpenAPI document stored in the registry.
- GetWorkspace - Get workspace
- GetWorkspaceFeatureFlags - Get workspace feature flags
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 | Variables |
---|---|---|
prod |
https://api.prod.speakeasyapi.dev |
None |
The default server can also be overridden globally by passing a URL to the serverUrl: str
optional parameter when initializing the SDK client instance. For example:
This SDK supports the following security schemes globally:
Name | Type | Scheme |
---|---|---|
APIKey |
apiKey | API key |
Bearer |
http | HTTP Bearer |
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.Operations;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
DeleteApiRequest req = new DeleteApiRequest() {
ApiID = "<value>",
VersionID = "<value>",
};
var res = await sdk.Apis.DeleteApiAsync(req);
// handle response
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 workspaceID
to "<value>"
at SDK initialization and then you do not have to pass the same value on calls to operations like GetWorkspace
. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
The following global parameter is available.
Name | Type | Required | Description |
---|---|---|---|
workspaceID | string | The WorkspaceID parameter. |
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
GetWorkspaceRequest req = new GetWorkspaceRequest() {};
var res = await sdk.Workspaces.GetWorkspaceAsync(req);
// handle response
Handling errors in this SDK should largely match your expectations. All operations return a response object or thow an exception. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate type.
Error Object | Status Code | Content Type |
---|---|---|
SpeakeasySDK.Models.Errors.Error | 5XX | application/json |
SpeakeasySDK.Models.Errors.SDKException | 4xx-5xx | / |
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using SpeakeasySDK.Models.Shared;
using System;
using SpeakeasySDK.Models.Errors;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
try
{
GetWorkspaceFeatureFlagsRequest req = new GetWorkspaceFeatureFlagsRequest() {};
var res = await sdk.Workspaces.GetWorkspaceFeatureFlagsAsync(req);
// handle response
}
catch (Exception ex)
{
if (ex is Error)
{
// handle exception
}
else if (ex is SpeakeasySDK.Models.Errors.SDKException)
{
// handle exception
}
}
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.GetWorkspaceAccessAsync(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),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.GetWorkspaceAccessAsync(req);
// handle response
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!