Skip to content

Blockdaemon/defi-api-go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for openapi

TEST

The Blockdaemon DeFi API provides a single interface to a multitude of DeFi projects and blockchains

Overview

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: 1.43.0
  • Package version: 1.0.0
  • Generator version: 7.7.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

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 openapi "github.com/Blockdaemon/defi-api-go-sdk"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

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 openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://svc.blockdaemon.com

Class Method HTTP request Description
ApprovalsAPI DeleteTokenApproval Delete /approval Delete an ERC20 token approval
ApprovalsAPI GetAllApprovals Get /approvals Get a list of ERC20 token approvals
ApprovalsAPI GetSupportedChains Get /approvals/supported-chains Get supported chains for token approvals
ApprovalsAPI GetTokenApproval Get /approval List ERC20 token approvals
ApprovalsAPI ModifyTokenApproval Post /approval Modify an ERC20 token approval
BalancesAPI GetBalances Get /balances Get token balances and market data for an account
BalancesAPI GetSupportedChainsForBalances Get /balances/supported-chains Get supported chains for token balance queries
ChainsAPI GetChains Get /chains Get supported blockchain networks with metadata
ExchangeAPI GetRoutes Get /exchange/routes Get a list of routes for swapping assets
ExchangeAPI GetStatus Get /exchange/status Get swap status
TokensAPI GetTokenTags Get /tokens/tags Get list of token tags
TokensAPI GetTokens Get /tokens Get list of supported tokens with metadata
TransactionsAPI GetTransactions Get /transactions Get transaction history for an account

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

bearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

apiKeyAuthHeader

  • Type: API key
  • API key parameter name: X-API-Key
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: X-API-Key and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"X-API-Key": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

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

Author

info@blockdaemon.com

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages