https://github.com/blockdaemon/defi-api-go-sdk
https://github.com/blockdaemon/defi-api-go-sdk
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/blockdaemon/defi-api-go-sdk
- Owner: Blockdaemon
- License: mit
- Created: 2025-02-20T11:30:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-07T11:46:11.000Z (about 1 year ago)
- Last Synced: 2025-03-07T12:29:15.586Z (about 1 year ago)
- Language: Shell
- Size: 115 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) 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:
```sh
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:
```go
import openapi "github.com/Blockdaemon/defi-api-go-sdk"
```
To use a proxy, set the environment variable `HTTP_PROXY`:
```go
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`.
```go
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`.
```go
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.
```go
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**](docs/ApprovalsAPI.md#deletetokenapproval) | **Delete** /approval | Delete an ERC20 token approval
*ApprovalsAPI* | [**GetAllApprovals**](docs/ApprovalsAPI.md#getallapprovals) | **Get** /approvals | Get a list of ERC20 token approvals
*ApprovalsAPI* | [**GetSupportedChains**](docs/ApprovalsAPI.md#getsupportedchains) | **Get** /approvals/supported-chains | Get supported chains for token approvals
*ApprovalsAPI* | [**GetTokenApproval**](docs/ApprovalsAPI.md#gettokenapproval) | **Get** /approval | List ERC20 token approvals
*ApprovalsAPI* | [**ModifyTokenApproval**](docs/ApprovalsAPI.md#modifytokenapproval) | **Post** /approval | Modify an ERC20 token approval
*BalancesAPI* | [**GetBalances**](docs/BalancesAPI.md#getbalances) | **Get** /balances | Get token balances and market data for an account
*BalancesAPI* | [**GetSupportedChainsForBalances**](docs/BalancesAPI.md#getsupportedchainsforbalances) | **Get** /balances/supported-chains | Get supported chains for token balance queries
*ChainsAPI* | [**GetChains**](docs/ChainsAPI.md#getchains) | **Get** /chains | Get supported blockchain networks with metadata
*ExchangeAPI* | [**GetRoutes**](docs/ExchangeAPI.md#getroutes) | **Get** /exchange/routes | Get a list of routes for swapping assets
*ExchangeAPI* | [**GetStatus**](docs/ExchangeAPI.md#getstatus) | **Get** /exchange/status | Get swap status
*TokensAPI* | [**GetTokenTags**](docs/TokensAPI.md#gettokentags) | **Get** /tokens/tags | Get list of token tags
*TokensAPI* | [**GetTokens**](docs/TokensAPI.md#gettokens) | **Get** /tokens | Get list of supported tokens with metadata
*TransactionsAPI* | [**GetTransactions**](docs/TransactionsAPI.md#gettransactions) | **Get** /transactions | Get transaction history for an account
## Documentation For Models
- [Account](docs/Account.md)
- [AccountSum](docs/AccountSum.md)
- [Action](docs/Action.md)
- [AllApprovalsResponse](docs/AllApprovalsResponse.md)
- [BalancesResponse](docs/BalancesResponse.md)
- [Chain](docs/Chain.md)
- [ChainBalance](docs/ChainBalance.md)
- [ChainSum](docs/ChainSum.md)
- [Chains](docs/Chains.md)
- [Error](docs/Error.md)
- [Estimate](docs/Estimate.md)
- [Extensions](docs/Extensions.md)
- [FeeCost](docs/FeeCost.md)
- [GasCost](docs/GasCost.md)
- [GasDetails](docs/GasDetails.md)
- [IncludedStep](docs/IncludedStep.md)
- [IncludedSteps](docs/IncludedSteps.md)
- [IntegrationDetails](docs/IntegrationDetails.md)
- [NativeCurrency](docs/NativeCurrency.md)
- [NetworkType](docs/NetworkType.md)
- [PortfolioViewSum](docs/PortfolioViewSum.md)
- [PortfolioViewSumSums](docs/PortfolioViewSumSums.md)
- [Route](docs/Route.md)
- [Routes](docs/Routes.md)
- [RoutesResponse](docs/RoutesResponse.md)
- [StatusChainDetail](docs/StatusChainDetail.md)
- [StatusEnum](docs/StatusEnum.md)
- [StatusResponse](docs/StatusResponse.md)
- [Tags](docs/Tags.md)
- [Token](docs/Token.md)
- [TokenAmount](docs/TokenAmount.md)
- [TokenApprovalData](docs/TokenApprovalData.md)
- [TokenApprovalDeletion](docs/TokenApprovalDeletion.md)
- [TokenApprovalModification](docs/TokenApprovalModification.md)
- [TokenApprovalResponse](docs/TokenApprovalResponse.md)
- [TokenList](docs/TokenList.md)
- [Tokens](docs/Tokens.md)
- [Transaction](docs/Transaction.md)
- [TransactionRequest](docs/TransactionRequest.md)
- [TransactionStatus](docs/TransactionStatus.md)
- [TransactionType](docs/TransactionType.md)
- [TransactionsResponse](docs/TransactionsResponse.md)
- [Transfer](docs/Transfer.md)
- [TransferType](docs/TransferType.md)
## Documentation For Authorization
Authentication schemes defined for the API:
### bearerAuth
- **Type**: HTTP Bearer token authentication
Example
```go
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
```go
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