Categorygithub.com/avianlabs/paxos-go
repositorypackage
0.0.5
Repository: https://github.com/avianlabs/paxos-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go API client for paxos

Welcome to Paxos APIs. At Paxos, our mission is to enable the movement of any asset, any time, in a trustworthy way. These APIs serve that mission by making it easier than ever for you to directly integrate our product capabilities into your application, leveraging the speed, stability, and security of the Paxos platform.

The documentation that follows gives you access to our Crypto Brokerage, Trading, and Exchange products. It includes APIs for market data, orders, and the held rate quote flow.

To test in our sandbox environment, sign up for an account. For more information about Paxos and our APIs, visit Paxos.com.

Generation

This SDK is generated from the OpenAPI spec found here.

The CLI command to generate it was:

openapi-generator generate -i paxos-v2.openapi.json -g go --package-name paxos --git-user-id avianlabs --git-repo-id paxos-go -t ./templates

Templates

The default generation will fail with this OpenAPI spec because there are enums with duplicate names. To solve this I've had to alter enum generation to suffix the datatype.

To do this, first we downloaded templates with the following command:

openapi-generator author template -g go -o ./templates

Then I updated the relevant template. In this case it was 'model_enum.mustache'. We instruct the generator to use our template using -t <templates folder>.

Changes post generation

  1. Revert changes to README.md so as not to loose these instructions!
  2. Revert changes to go.mod to keep generated code using specific go version and dependency versions.

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: 2.0
  • Package version: 1.0.0
  • Generator version: 7.6.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/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import paxos "github.com/avianlabs/paxos-go"

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 paxos.ContextServerIndex of type int.

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

Templated Server URL

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

ctx := context.WithValue(context.Background(), paxos.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 paxos.ContextOperationServerIndices and paxos.ContextOperationServerVariables context maps.

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

Documentation for API Endpoints

All URIs are relative to https://api.paxos.com/v2

ClassMethodHTTP requestDescription
AccountMembersAPIAddAccountMembersPost /identity/account-membersAdd Account Members
AccountMembersAPIDeleteAccountMemberDelete /identity/account-members/{id}Remove Account Member
AccountsAPICreateAccountPost /identity/accountsCreate Account
AccountsAPIGetAccountGet /identity/accounts/{id}
AccountsAPIListAccountsGet /identity/accountsList Accounts
AccountsAPIUpdateAccountPut /identity/accountsUpdate Account
CryptoWithdrawalsAPICreateCryptoWithdrawalPost /transfer/crypto-withdrawalsCreate Crypto Withdrawal
DepositAddressesAPICreateDepositAddressPost /transfer/deposit-addressesCreate Deposit Address
DepositAddressesAPIListDepositAddressesGet /transfer/deposit-addressesList Deposit Addresses
ExchangePublicAPIListProfileExecutionsGet /profiles/{profile_id}/executionsList Executions
ExchangePublicAPIListProfileOrdersGet /profiles/{profile_id}/ordersList Orders
FeesAPICreateCryptoWithdrawalFeePost /transfer/fees/crypto-withdrawalCreate Crypto Withdrawal Fee
FiatTransfersAPICreateFiatAccountPost /transfer/fiat-accountsCreate Fiat Account
FiatTransfersAPICreateFiatDepositInstructionsPost /transfer/fiat-deposit-instructionsCreate Fiat Deposit Instructions
FiatTransfersAPICreateFiatWithdrawalPost /transfer/fiat-withdrawalsCreate Fiat Withdrawal
FiatTransfersAPIDeleteFiatAccountDelete /transfer/fiat-accounts/{id}Delete Fiat Account
FiatTransfersAPIGetFiatAccountGet /transfer/fiat-accounts/{id}Get Fiat Account
FiatTransfersAPIGetFiatDepositInstructionsGet /transfer/fiat-deposit-instructions/{id}Get Fiat Deposit Instructions
FiatTransfersAPIListFiatAccountsGet /transfer/fiat-accountsList Fiat Accounts
FiatTransfersAPIListFiatDepositInstructionsGet /transfer/fiat-deposit-instructionsList Fiat Deposit Instructions
FiatTransfersAPIUpdateFiatAccountPut /transfer/fiat-accounts/{id}Update Fiat Account
IdentityAPICreateIdentityPost /identity/identitiesCreate Identity
IdentityAPIGetIdentityGet /identity/identities/{id}Get Identity
IdentityAPIListIdentitiesGet /identity/identitiesList Identities
IdentityAPIUpdateIdentityPut /identity/identities/{id}Update Identity
IdentityCredentialsAPIRetryIdVerificationPost /identity/identities/{id}/retry-id-verificationRetry Id Verification
IdentityCredentialsAPISetVerifierCredentialsPost /identity/verifier-credentialsSet Verifier Credentials
IdentityDocumentsAPIDocumentUploadPut /identity/identities/{identity_id}/documentsDocument Upload
IdentityDocumentsAPIListIdentityDocumentsGet /identity/identities/{identity_id}/documentsList Identity Documents
InstitutionMembersAPIAddInstitutionMembersPost /identity/institution-membersAdd Institution Members
InstitutionMembersAPIDeleteInstitutionMemberDelete /identity/institution-members/{id}Remove Institution Member
InternalTransfersAPICreateInternalTransferPost /transfer/internalCreate Internal Transfer
LimitsAPIListTransferLimitsGet /transfer/limits/utilizationsList Transfer Limits
MarketDataAPIGetOrderBookGet /markets/{market}/order-bookGet Order Book
MarketDataAPIGetTickerGet /markets/{market}/tickerGet Ticker
MarketDataAPIListMarketsGet /marketsList Markets
MarketDataAPIListRecentExecutionsGet /markets/{market}/recent-executionsList Recent Executions
OrdersAPICancelOrderDelete /profiles/{profile_id}/orders/{id}Cancel Order
OrdersAPICreateOrderPost /profiles/{profile_id}/ordersCreate Order
OrdersAPIGetOrderGet /profiles/{profile_id}/orders/{id}Get Order
OrdersAPIListExecutionsGet /executionsList Executions
OrdersAPIListOrdersGet /ordersList Orders
PricingAPIListHistoricalPricesGet /markets/{market}/historical-pricesList Historical Prices
PricingAPIListPricesGet /all-markets/pricesList Prices
PricingAPIListTickersGet /all-markets/tickerList Tickers
ProfilesAPICreateProfilePost /profilesCreate Profile
ProfilesAPIGetProfileGet /profiles/{profile_id}Get Profile
ProfilesAPIGetProfileBalanceGet /profiles/{profile_id}/balances/{asset}Get Profile Balance
ProfilesAPIListProfileBalancesGet /profiles/{profile_id}/balancesList Profile Balances
ProfilesAPIListProfilesGet /profilesList Profiles
QuoteExecutionsAPICreateQuoteExecutionPost /profiles/{profile_id}/quote-executionsCreate Quote Execution
QuoteExecutionsAPIGetQuoteExecutionGet /profiles/{profile_id}/quote-executions/{id}Get Quote Execution
QuoteExecutionsAPIListQuoteExecutionsGet /profiles/{profile_id}/quote-executionsList Quote Executions
QuotesAPIListQuotesGet /quotesList Quotes
SandboxDepositsAPICreateSandboxDepositPost /sandbox/profiles/{profile_id}/depositCreate Sandbox Deposit
SandboxFiatTransfersAPIInitiateSandboxFiatDepositPost /sandbox/fiat-depositsInitiate Sandbox Fiat Deposit
SandboxIdentityAPISandboxSetIdentityStatusPut /identity/identities/{id}/sandbox-statusSandbox Set Identity Status
StablecoinConversionAPICancelStablecoinConversionDelete /conversion/stablecoins/{id}Cancel Stablecoin Conversion
StablecoinConversionAPICreateStablecoinConversionPost /conversion/stablecoinsCreate Stablecoin Conversion
StablecoinConversionAPIGetStablecoinConversionGet /conversion/stablecoins/{id}Get Stablecoin Conversion
StablecoinConversionAPIListStablecoinConversionsGet /conversion/stablecoinsList Stablecoin Conversions
TaxFormsAPIListTaxFormRevisionsGet /tax/tax-form-revisionsList Tax Form Revisions
TaxFormsAPIListTaxFormsGet /tax/tax-formsList Tax Forms
TaxLotAPIGetTaxLotGet /tax/tax-lots/{id}Get Tax Lot
TaxLotAPIListTaxLotsGet /tax/tax-lotsList Tax Lots
TaxLotAPIUpdateTaxLotPut /tax/tax-lots/{id}Update Tax Lot
TransfersAPIGetTransferGet /transfer/transfers/{id}Get Transfer
TransfersAPIListTransfersGet /transfer/transfersList Transfers

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

OAuth2

  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes:
  • funding:read_profile: Read profile and balance data
  • exchange:read_quote: Read quotes and quote history
  • exchange:write_quote_execution: Execute on quoted prices
  • exchange:read_quote_execution: Read quote executions
  • exchange:write_order: Create and Cancel Orders
  • exchange:read_order: Read Orders and Executions
  • exchange:historical_prices: Read Historical Pricing Data
  • transfer:read_transfer: Read deposit and withdrawal transfers
  • transfer:read_deposit_address: Read deposit addresses
  • transfer:write_deposit_address: Create and manage deposit addresses
  • fee:write_crypto_withdrawal_fee: Create crypto withdrawal fees
  • transfer:write_crypto_withdrawal: Create crypto withdrawal transfers
  • conversion:read_conversion_stablecoin: Retrieve requested or completed conversions
  • conversion:write_conversion_stablecoin: Create or cancel a conversion request

Example

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

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, paxos.ContextOAuth2, tokenSource)
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