The Tyk Dashboard API offers granular, programmatic access to a centralised database of resources that your Tyk nodes can pull from. This API has a dynamic user administrative structure which means the secret key that is used to communicate with your Tyk nodes can be kept secret and access to the wider management functions can be handled on a user-by-user and organisation-by-organisation basis.
A common question around using a database-backed configuration is how to programmatically add API definitions to your Tyk nodes, the Dashboard API allows much more fine-grained, secure and multi-user access to your Tyk cluster, and should be used to manage a database-backed Tyk node.
The Tyk Dashboard API works seamlessly with the Tyk Dashboard (and the two come bundled together).
The Dashboard API provides a more structured security layer to managing Tyk nodes.
With the Dashboard API and a database-backed Tyk setup, (and to an extent with file-based API setups - if diligence is used in naming and creating definitions), the following security model is applied to the management of Upstream APIs:
- Organisations: All APIs are owned by an organisation, this is designated by the 'OrgID' parameter in the API Definition.
- Users: All users created in the Dashboard belong to an organisation (unless an exception is made for super-administrative access).
- APIs: All APIs belong to an Organisation and only Users that belong to that organisation can see the analytics for those APIs and manage their configurations.
- API Keys: API Keys are designated by organisation, this means an API key that has full access rights will not be allowed to access the APIs of another organisation on the same system, but can have full access to all APIs within the organisation.
- Access Rights: Access rights are stored with the key, this enables a key to give access to multiple APIs, this is defined by the session object in the core Tyk API.
In order to use the Dashboard API, you'll need to get the 'Tyk Dashboard API Access Credentials' secret from your user profile on the Dashboard UI.
The secret you set should then be sent along as a header with each Dashboard API Request in order for it to be successful:
authorization:
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 5.7.1
- Package version: 1.0.0
- Generator version: 7.10.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://tyk.io/contact
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import dashboard "github.com/TykTechnologies/dashboard-sdk"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
For using other server than the one defined on index 0 set context value dashboard.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), dashboard.ContextServerIndex, 1)
Templated server URL is formatted using default variables from configuration or from context value dashboard.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), dashboard.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
Each operation can use different server URL defined using OperationServers
map in the Configuration
.
An operation is uniquely identified by "{classname}Service.{nickname}"
string.
Similar rules for overriding default operation server index and variables applies by using dashboard.ContextOperationServerIndices
and dashboard.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), dashboard.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), dashboard.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
All URIs are relative to https://localhost:8080
Class | Method | HTTP request | Description |
---|---|---|---|
APIsAPI | DeleteApi | Delete /api/apis/{apiId} | Delete a single API by ID |
APIsAPI | GetAPIExample | Get /api/examples/{location} | Get details of a single example API definition. |
APIsAPI | GetAPIExamples | Get /api/examples | Get a list of example API definitions. |
APIsAPI | GetAPIGroups | Get /api/apis/groups | Get API Groups. |
APIsAPI | GetAllApiCategories | Get /api/apis/categories | Get API Categories |
APIsAPI | GetApi | Get /api/apis/{apiId} | Get a single API by ID |
APIsAPI | GetApiAccessRights | Get /api/apis/{apiID}/access | Get API access rights (users and userGroups) |
APIsAPI | GetApiUrl | Get /api/apis/{apiId}/url | Get API URLs |
APIsAPI | GetApis | Get /api/apis | Get List of APIs |
APIsAPI | PostApis | Post /api/apis | Create API Definition |
APIsAPI | PutApi | Put /api/apis/{apiId} | Update API Definition |
APIsAPI | SearchApis | Get /api/apis/search | Search List of APIs |
APIsAPI | UpdateApiAccessRights | Put /api/apis/{apiID}/access | Update API access rights (users and userGroups) |
AdditionalPermissionsAPI | ListAdditionalPermissions | Get /api/org/permissions | List additional permissions. |
AdditionalPermissionsAPI | UpdateAdditionalPermissions | Put /api/org/permissions | Add/Delete/Update additional permission. |
AnalyticsAPI | GetAnalyticsOfApiKey | Get /api/activity/keys/{keyHash}/{startDay}/{startMonth}/{startYear}/{EndDay}/{EndMonth}/{EndYear} | Analytics of API Key. |
AnalyticsAPI | GetAnalyticsOfOauthClientId | Get /api/activity/oauthid/{OAuthClientID}/{startDay}/{startMonth}/{startYear}/{EndDay}/{EndMonth}/{EndYear} | Analytics of Oauth Client ID. |
AssetsAPI | AddAsset | Post /api/assets | Create an asset |
AssetsAPI | DeleteAsset | Delete /api/assets/{assetID} | Delete an asset by ID. |
AssetsAPI | GetAsset | Get /api/assets/{assetID} | Retrieve an asset. |
AssetsAPI | ListAssets | Get /api/assets | Retrieve list of assets. |
AssetsAPI | UpdateAsset | Put /api/assets/{assetID} | Update an asset by ID. |
AuditLogsAPI | GetAuditLogs | Get /api/audit-logs | List audit logs |
BasicAuthenticationAPI | CreateBasicAuthUser | Post /api/apis/keys/basic/{username} | Create a Basic Auth User. |
CertificatesAPI | CreateCertificates | Post /api/certs | Create a certificate in Tyk org cert store. |
CertificatesAPI | DeleteCertificateDependencies | Delete /api/certs/dependencies/{certId} | Delete Certificate dependencies. |
CertificatesAPI | DeleteCertificates | Delete /api/certs/{certId} | Delete Certificate. |
CertificatesAPI | GetCertificate | Get /api/certs/{certId} | Get single certificate with ID. |
CertificatesAPI | GetCertificateDependencies | Get /api/certs/dependencies/{certId} | Get Certificate Dependencies. |
CertificatesAPI | ListCertificates | Get /api/certs | List Certificates. |
CertificatesAPI | ListDetailedCertificates | Get /api/certs/details | List all certificates details. |
KeysAPI | AddKey | Post /api/keys | Create a key. |
KeysAPI | CreateCustomKey | Post /api/keys/{keyId} | Create custom key. |
KeysAPI | DeleteApiKeyDetail | Delete /api/apis/{apiID}/keys/{keyID} | Delete key with API ID and key ID. |
KeysAPI | DeleteKey | Delete /api/keys/{keyId} | Delete key. |
KeysAPI | GetApiKeyDetail | Get /api/apis/{apiID}/keys/{keyID} | Get key details with API ID and key ID. |
KeysAPI | GetKeyDetail | Get /api/keys/{keyId} | Get key Details. |
KeysAPI | GetKeysDetailed | Get /api/keys/detailed | List All the Keys info. |
KeysAPI | ListApiKeys | Get /api/apis/{apiID}/keys | List keys by API. |
KeysAPI | ListKeys | Get /api/apis/keys | List All the keys. |
KeysAPI | SearchKeys | Get /api/apis/{apiId}/keys/search | Search keys by API. |
KeysAPI | UpdateApiKeyDetail | Put /api/apis/{apiID}/keys/{keyID} | With API ID and key ID. |
KeysAPI | UpdateKeyDetail | Put /api/keys/{keyId} | Update key. |
KeysAPI | ValidateAKeyDefinition | Post /api/keys/preview | This will validate a key definition. |
OASAPIsAPI | CreateApiOAS | Post /api/apis/oas | Create OAS API. |
OASAPIsAPI | DeleteOASApi | Delete /api/apis/oas/{apiId} | Delete OAS API. |
OASAPIsAPI | DownloadApiOASPublic | Get /api/apis/oas/{apiId}/export | Export OAS API. |
OASAPIsAPI | DryRunApiOAS | Post /api/apis/oas/dry-run | Dry Run OAS. |
OASAPIsAPI | GetApiCategories | Get /api/apis/oas/{apiId}/categories | Get OAS API's Categories. |
OASAPIsAPI | GetOASAPIDetails | Get /api/apis/oas/{apiId} | Get OAS API details. |
OASAPIsAPI | ImportOAS | Post /api/apis/oas/import | Import OAS. |
OASAPIsAPI | ListOASApiVersions | Get /api/apis/oas/{apiId}/versions | List OAS API versions. |
OASAPIsAPI | PatchApiOAS | Patch /api/apis/oas/{apiId} | Patch a single OAS API by ID. |
OASAPIsAPI | UpdateApiCategories | Put /api/apis/oas/{apiId}/categories | Update OAS API categories. |
OASAPIsAPI | UpdateApiOAS | Put /api/apis/oas/{apiId} | Update OAS API. |
OauthAPI | CreateNewClientApp | Post /api/apis/oauth/{apiId} | Create a new OAuth2.0 client. |
OauthAPI | DeleteOathClient | Delete /api/apis/oauth/{apiId}/{clientId} | Delete OAuth client. |
OauthAPI | GetClientTokens | Get /api/apis/oauth/{apiId}/{clientId}/tokens | List OAuth client tokens. |
OauthAPI | GetOAuthClientDetail | Get /api/apis/oauth/{apiId}/{clientId} | Get single OAuth client details. |
OauthAPI | GetOathClientsList | Get /api/apis/oauth/{apiId} | List OAuth clients. |
OpenPolicyAgentAPI | GetOPARules | Get /api/org/opa | List OPA rules. |
OpenPolicyAgentAPI | UpdateOrgOPARules | Put /api/org/opa | Update OPA rules. |
PoliciesAPI | DeletePolicy | Delete /api/portal/policies/{id} | Delete a single policy by ID. |
PoliciesAPI | GetPolicies | Get /api/portal/policies | Get list portal policies. |
PoliciesAPI | GetPolicy | Get /api/portal/policies/{id} | Get a single policy by ID. |
PoliciesAPI | PostPolicies | Post /api/portal/policies | Create policy definition. |
PoliciesAPI | PutPolicies | Put /api/portal/policies/{id} | Update policy definition. |
PoliciesAPI | SearchPolicies | Get /api/portal/policies/search | Search list of policies. |
ProxyAPI | ProxyRequest | Post /api/proxy | Proxy API request |
SchemaAPI | GetSchema | Get /api/schema | Get OAS schema. |
SingleSignOnAPI | GenerateAuthToken | Post /api/sso | Generate authentication token. |
StreamsAPIsAPI | CreateStreamsApi | Post /api/apis/streams | Create Streams API. |
StreamsAPIsAPI | DeleteStreamsApi | Delete /api/apis/streams/{apiId} | Delete Streams API. |
StreamsAPIsAPI | GetStreamsAPIDetails | Get /api/apis/streams/{apiId} | Get Streams API details. |
StreamsAPIsAPI | PatchApiStreams | Patch /api/apis/streams/{apiId} | Patch a single Streams API by ID. |
StreamsAPIsAPI | UpdateStreamsApi | Put /api/apis/streams/{apiId} | Update Streams API. |
SystemAPI | GetSystemStats | Get /api/system/stats | Get system usage info. |
UserGroupAPI | CreateUserGroup | Post /api/usergroups | Create user group. |
UserGroupAPI | DeleteUserGroup | Delete /api/usergroups/{groupId} | Delete user group. |
UserGroupAPI | GetUserGroup | Get /api/usergroups/{groupId} | Get user group details. |
UserGroupAPI | ListUserGroups | Get /api/usergroups | List user groups. |
UserGroupAPI | UpdateUserGroup | Put /api/usergroups/{groupId} | Update user group. |
UsersAPI | AddUser | Post /api/users | Add user. |
UsersAPI | CurrentUserDetail | Get /api/users/me | Get current user. |
UsersAPI | DeleteUser | Delete /api/users/{userId} | Delete a user. |
UsersAPI | GetUser | Get /api/users/{userId} | Get user details. |
UsersAPI | GetUsers | Get /api/users | List users |
UsersAPI | ResetUserKey | Put /api/users/{userId}/actions/key/reset | Reset user Dashboard API access credentials. |
UsersAPI | RevokeUser | Put /api/users/{userId}/actions/revoke | Revoke user. |
UsersAPI | SearchUser | Post /api/users/search | Search user with email. |
UsersAPI | SearchUserGet | Get /api/users/search | Search Users(Deprecated) |
UsersAPI | SetUserPassword | Post /api/users/{userId}/actions/reset | Set user password. |
UsersAPI | UpdateUser | Put /api/users/{userId} | Update user. |
WebhooksAPI | CreateWebhook | Post /api/hooks | Create a webhook. |
WebhooksAPI | DeleteWebhook | Delete /api/hooks/{hookId} | Delete web hook. |
WebhooksAPI | GetWebhookDetail | Get /api/hooks/{hookId} | Get single webhook. |
WebhooksAPI | GetWebhookList | Get /api/hooks | List webhooks. |
WebhooksAPI | UpdateWebhook | Put /api/hooks/{hookId} | Update Webhook |
- APICertificateStatusMessage
- APIDefinition
- APIDefinitionBasicAuth
- APIDefinitionOauthMeta
- APILimit
- AccessDefinition
- AccessManagementPayload
- AccessSpec
- AddAssetRequest
- AggregateAnalyticsData
- AllCategoriesResponse
- AllKeys
- Allowance
- AnalyticsPluginConfig
- ApiDefinitionWrapper
- ApiDefinitionsResponse
- ApiImportByUrlPayload
- ApiResponse
- ApiStatusMessage
- Asset
- AuditLog
- AuditLogs
- AuthConfig
- AuthProviderMeta
- AuthSource
- AuthSources
- Authentication
- AuthenticationPlugin
- CORS
- CORSConfig
- Cache
- CacheMeta
- CacheOptions
- CachePlugin
- CategoriesPayload
- CategoryCount
- CertificateBasics
- CertificateDependencies
- CertificateDetailedList
- CertificateList
- CertificatePinning
- CertsCertificateBasics
- CertsCertificateMeta
- CheckCommand
- CircuitBreaker
- CircuitBreakerMeta
- ClientCertificates
- ClientToPolicy
- Components
- Components1
- Contact
- Contact1
- ContextVariables
- CreateApiOASRequest
- CreateStreamsApiRequest
- CreateWebhookRequest
- CustomPlugin
- CustomPluginAuthentication
- DatasourceMappingConfiguration
- DatasourceSourceConfig
- DatasourceTypeFieldConfiguration
- DcrpRegistration
- DetailedActivityLogs
- DetailedExampleAPIMetadata
- DetailedTracing
- Domain
- DomainToCertificate
- DryRunApiOAS200Response
- DryRunRequest
- EndPointMeta
- EndpointMethodMeta
- EndpointPostPlugin
- EnforceTimeout
- EntityStats
- ErrorResponse
- EventHandler
- EventHandlerMetaConfig
- EventHandlerTriggerConfig
- ExampleAPIMetadata
- ExtendedPathsSet
- ExternalDocs
- ExternalDocumentation
- ExternalOAuth
- FieldAccessDefinition
- FieldLimits
- FromOASExamples
- GatewayTags
- Global
- GlobalRateLimit
- GoPluginMeta
- GraphQLConfig
- GraphQLEngineConfig
- GraphQLEngineDataSource
- GraphQLFieldConfig
- GraphQLIntrospectionConfig
- GraphQLPlayground
- GraphQLProxyConfig
- GraphQLProxyFeaturesConfig
- GraphQLResponseExtensions
- GraphQLSubgraphConfig
- GraphQLSubgraphEntity
- GraphQLSupergraphConfig
- GraphQLTypeFields
- GraphqlType
- HMAC
- HardTimeoutMeta
- Header
- HeaderInjectionMeta
- HookReference
- HostCheckObject
- IDExtractor
- IDExtractorConfig
- ImportOASRequest
- IndividualStats
- Info
- Info1
- InfoType2
- Internal
- InternalMeta
- Introspection
- IntrospectionCache
- JWTValidation
- KeyData
- Keys
- KeysDetailed
- License
- License1
- ListCertificates200Response
- ListenPath
- MethodTransformMeta
- Middleware
- MiddlewareDefinition
- MiddlewareIdExtractor
- MiddlewareSection
- MockResponse
- MockResponseMeta
- Model30
- MutualTLS
- NewAdditionalPermissions
- NewClientRequest
- NewOPARules
- NewOPARulesOpenPolicy
- NotificationsManager
- OAS
- OASSchemaResponse
- OAuthApps
- OAuthClient
- OAuthClientToken
- OIDC
- OIDProviderConfig
- OpenIDOptions
- Operation
- OperationType2
- PatchApiOASRequest
- PatchApiStreamsRequest
- PathItem
- PersistGraphQLMeta
- PinnedPublicKey
- PluginBundle
- PluginConfig
- PluginConfigData
- Policy
- PolicyPartitions
- PostAuthenticationPlugin
- PostPlugin
- PrePlugin
- Provider
- ProviderType2
- ProxyConfig
- ProxyConfigTransport
- ProxyRequest
- ProxyResponse
- RateLimit
- RateLimitEndpoint
- RateLimitMeta
- RateLimitSmoothing
- RequestHeadersRewriteConfig
- RequestSigningMeta
- RequestSizeLimit
- RequestSizeMeta
- ResponsePlugin
- ResponseProcessor
- ResultId
- ResultUnit
- ReturnDataStruct
- RoutingTrigger
- RoutingTriggerOptions
- SSOAccessData
- ScopeClaim
- ScopeToPolicy
- Scopes
- ScopesType2
- Server
- Server1
- ServerType2
- ServerVariable
- ServerVariable1
- ServiceDiscovery
- ServiceDiscoveryCache
- ServiceDiscoveryConfiguration
- SessionEndpoint
- SessionEndpointMethod
- SessionEndpointRateLimit
- SessionProviderMeta
- SessionState
- SessionStateBasicAuthData
- SessionStateJwtData
- SessionStateMonitor
- SignatureConfig
- State
- StringRegexMap
- SystemStatsResp
- Tag
- Tag1
- TemplateData
- TemplateMeta
- Test
- TrackEndpoint
- TrackEndpointMeta
- TrafficLogs
- TransformBody
- TransformHeaders
- TransformJQMeta
- TransformRequestMethod
- UDGGlobalHeader
- URLRewrite
- URLRewriteMeta
- URLRewriteRule
- URLRewriteTrigger
- URLVals
- UpdateUserRequest
- Upstream
- UptimeTests
- UptimeTestsConfig
- User
- UserGroup
- UserGroups
- UserPassword
- UserSearchPayload
- UserSearchPayloadFilters
- Users
- ValidatePathMeta
- ValidateRequest
- ValidateRequestMeta
- VersionData
- VersionDefinition
- VersionInfo
- VersionInfoPaths
- VersionMeta
- VersionMetas
- VersionToID
- Versioning
- VirtualEndpoint
- VirtualMeta
- WebHookHandlerConf
- WebHooks
- XTykAPIGateway
- XTykApiGateway
- XTykStreaming
- XTykStreamingXTykStreaming
Authentication schemes defined for the API:
- Type: HTTP Bearer token authentication
Example
auth := context.WithValue(context.Background(), dashboard.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime