swagger

package module
v0.0.0-...-dc33cdb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2020 License: MIT Imports: 21 Imported by: 0

README

Go API client for swagger

The CryptoWeather API allows for access to all of the cryptocurrency data and market forecast services provided. There are two primary categories of routes, public and private, where public routes are accessible to the general public and do not require API authentication, and private routes, which require API authentication. ## General Overview 1. All API methods adhere to RESTful best practices as closely as possible. As such, all API calls will be made via the standard HTTP protocol using the GET/POST/PUT/DELETE request types. 2. Every request returns the status as a JSON response with the following: - success, true if it was successful - code, the http status code (also in the response header) - 200 if response is successful - 400 if bad request - 401 if authorization JWT is wrong or limit exceeded - 404 wrong route - 500 for any internal errors - status, the status of the request, default success - errors, an array of any relevant error details 3. For any requests that are not successful an error message is specified and returned as an array for the errors key in the JSON response. 4. All authentication uses JSON Web Tokens (JWT), which is set as the Authorization entry in the header, see the following for more details. - http://jwt.io - https://scotch.io/tutorials/the-anatomy-of-a-json-web-token ## Code Example The following is a code example in Python, which demonstrates using the Python Requests library for both the public and private API routes. import requests HOST = \"https://api.cryptoweather.ai/v1\" # Your API key (JWT) API_KEY = \"<YOUR API KEY>\" # Example public request, no API key required. requests.get(\"{}/public/symbols\".format(HOST)).json() # Get the current btc price using the public route requests.get(\"{}/public/price-current/{}\".format(HOST, \"btc\")).json() # Example private request, API key required. Get the btc hourly forecasts headers = {\"Authorization\": \"Bearer {}\".format(API_KEY)} requests.get(\"{}/private/forecast/{}/{}\".format(HOST, \"btc\", \"1h\"), headers=headers).json()

Overview

This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you can easily generate an API client.

  • API version:
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.languages.GoClientCodegen

Installation

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

import "./swagger"

Documentation for API Endpoints

All URIs are relative to https://api.cryptoweather.ai

Class Method HTTP request Description
PrivateApi V1PrivateAccuracySymbolIntervalPeriodGet Get /v1/private/accuracy/{symbol}/{interval}/{period} Accuracy
PrivateApi V1PrivateForecastAccuracySymbolIntervalPeriodGet Get /v1/private/forecast-accuracy/{symbol}/{interval}/{period} Forecast Accuracy
PrivateApi V1PrivateForecastSymbolIntervalGet Get /v1/private/forecast/{symbol}/{interval} Forecast
PrivateApi V1PrivateForecastTimeSymbolIntervalPeriodGet Get /v1/private/forecast-time/{symbol}/{interval}/{period} Forecast Time
PrivateApi V1PrivateTrendSymbolGet Get /v1/private/trend/{symbol} Trend
PrivateApi V1PrivateTrendTabularGet Get /v1/private/trend-tabular Trend Tabular
PublicApi V1PublicPriceChangeSymbolGet Get /v1/public/price-change/{symbol} Price Change
PublicApi V1PublicPriceCurrentSymbolGet Get /v1/public/price-current/{symbol} Price Current
PublicApi V1PublicPriceHistorySymbolPeriodIntervalGet Get /v1/public/price-history/{symbol}/{period}/{interval} Price History
PublicApi V1PublicSummaryGet Get /v1/public/summary Summary
PublicApi V1PublicSymbolsGet Get /v1/public/symbols Symbols
PublicApi V1PublicTrendSymbolGet Get /v1/public/trend/{symbol} Trend

Documentation For Models

Documentation For Authorization

oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL:
  • Scopes: N/A

Example

auth := context.WithValue(context.Background(), sw.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, sw.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Author

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	PrivateApi *PrivateApiService

	PublicApi *PublicApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the CryptoWeather API v In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the swagger operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type AccuracyRoute

type AccuracyRoute struct {
}

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type DefaultResponse

type DefaultResponse struct {
	Success bool          `json:"success"`
	Code    int32         `json:"code"`
	Status  string        `json:"status"`
	Errors  []interface{} `json:"errors,omitempty"`
}

type ForecastAccuracyRoute

type ForecastAccuracyRoute struct {
}

type ForecastRoute

type ForecastRoute struct {
}

type ForecastTimeRoute

type ForecastTimeRoute struct {
}

type GenericSwaggerError

type GenericSwaggerError struct {
	// contains filtered or unexported fields
}

GenericSwaggerError Provides access to the body, error and model on returned errors.

func (GenericSwaggerError) Body

func (e GenericSwaggerError) Body() []byte

Body returns the raw bytes of the response

func (GenericSwaggerError) Error

func (e GenericSwaggerError) Error() string

Error returns non-empty string if there was an error.

func (GenericSwaggerError) Model

func (e GenericSwaggerError) Model() interface{}

Model returns the unpacked model of the error

type PriceChangeRoute

type PriceChangeRoute struct {
}

type PriceCurrentRoute

type PriceCurrentRoute struct {
}

type PriceHistoryRoute

type PriceHistoryRoute struct {
}

type PrivateAccuracyResponse

type PrivateAccuracyResponse struct {
	Success bool                         `json:"success"`
	Code    int32                        `json:"code"`
	Status  string                       `json:"status"`
	Data    *PrivateAccuracyResponseData `json:"data"`
	Errors  []interface{}                `json:"errors,omitempty"`
}

type PrivateAccuracyResponseData

type PrivateAccuracyResponseData struct {
	Rmse float32   `json:"rmse"`
	Mae  float32   `json:"mae"`
	R2   float32   `json:"r2"`
	Ci   []float32 `json:"ci"`
}

type PrivateApiService

type PrivateApiService service

func (*PrivateApiService) V1PrivateAccuracySymbolIntervalPeriodGet

func (a *PrivateApiService) V1PrivateAccuracySymbolIntervalPeriodGet(ctx context.Context, symbol string, interval string, period string, localVarOptionals *PrivateApiV1PrivateAccuracySymbolIntervalPeriodGetOpts) (PrivateAccuracyResponse, *http.Response, error)

func (*PrivateApiService) V1PrivateForecastAccuracySymbolIntervalPeriodGet

func (a *PrivateApiService) V1PrivateForecastAccuracySymbolIntervalPeriodGet(ctx context.Context, symbol string, interval string, period string, localVarOptionals *PrivateApiV1PrivateForecastAccuracySymbolIntervalPeriodGetOpts) (PrivateForecastAccuracyResponse, *http.Response, error)

func (*PrivateApiService) V1PrivateForecastSymbolIntervalGet

func (a *PrivateApiService) V1PrivateForecastSymbolIntervalGet(ctx context.Context, symbol string, interval string, localVarOptionals *PrivateApiV1PrivateForecastSymbolIntervalGetOpts) (PrivateForecastResponse, *http.Response, error)

func (*PrivateApiService) V1PrivateForecastTimeSymbolIntervalPeriodGet

func (a *PrivateApiService) V1PrivateForecastTimeSymbolIntervalPeriodGet(ctx context.Context, symbol string, interval string, period string, localVarOptionals *PrivateApiV1PrivateForecastTimeSymbolIntervalPeriodGetOpts) (PrivateForecastTimeResponse, *http.Response, error)

func (*PrivateApiService) V1PrivateTrendSymbolGet

func (a *PrivateApiService) V1PrivateTrendSymbolGet(ctx context.Context, symbol string, localVarOptionals *PrivateApiV1PrivateTrendSymbolGetOpts) (PublicTrendResponse, *http.Response, error)

func (*PrivateApiService) V1PrivateTrendTabularGet

type PrivateApiV1PrivateAccuracySymbolIntervalPeriodGetOpts

type PrivateApiV1PrivateAccuracySymbolIntervalPeriodGetOpts struct {
	Cookie optional.String
	XCsrf  optional.String
}

type PrivateApiV1PrivateForecastAccuracySymbolIntervalPeriodGetOpts

type PrivateApiV1PrivateForecastAccuracySymbolIntervalPeriodGetOpts struct {
	Cookie optional.String
	XCsrf  optional.String
}

type PrivateApiV1PrivateForecastSymbolIntervalGetOpts

type PrivateApiV1PrivateForecastSymbolIntervalGetOpts struct {
	Cookie optional.String
	XCsrf  optional.String
}

type PrivateApiV1PrivateForecastTimeSymbolIntervalPeriodGetOpts

type PrivateApiV1PrivateForecastTimeSymbolIntervalPeriodGetOpts struct {
	Cookie optional.String
	XCsrf  optional.String
}

type PrivateApiV1PrivateTrendSymbolGetOpts

type PrivateApiV1PrivateTrendSymbolGetOpts struct {
	Cookie optional.String
	XCsrf  optional.String
}

type PrivateApiV1PrivateTrendTabularGetOpts

type PrivateApiV1PrivateTrendTabularGetOpts struct {
	Cookie optional.String
	XCsrf  optional.String
}

type PrivateForecastAccuracyResponse

type PrivateForecastAccuracyResponse struct {
	Success bool                                 `json:"success"`
	Code    int32                                `json:"code"`
	Status  string                               `json:"status"`
	Data    *PrivateForecastAccuracyResponseData `json:"data"`
	Errors  []interface{}                        `json:"errors,omitempty"`
}

type PrivateForecastAccuracyResponseData

type PrivateForecastAccuracyResponseData struct {
	Accuracy float32 `json:"accuracy"`
}

type PrivateForecastResponse

type PrivateForecastResponse struct {
	Success bool                         `json:"success"`
	Code    int32                        `json:"code"`
	Status  string                       `json:"status"`
	Data    *PrivateForecastResponseData `json:"data"`
	Errors  []interface{}                `json:"errors,omitempty"`
}

type PrivateForecastResponseData

type PrivateForecastResponseData struct {
	Forecast []PrivateForecastResponseDataForecast `json:"forecast"`
}

type PrivateForecastResponseDataForecast

type PrivateForecastResponseDataForecast struct {
	TimeStart     float32 `json:"time_start"`
	TimeEnd       float32 `json:"time_end"`
	Low           float32 `json:"low"`
	WeightedPrice float32 `json:"weighted_price"`
	High          float32 `json:"high"`
	Confidence    float32 `json:"confidence"`
	ChangeUsd     float32 `json:"change_usd"`
	ChangePct     float32 `json:"change_pct"`
}

type PrivateForecastTimeResponse

type PrivateForecastTimeResponse struct {
	Success bool                             `json:"success"`
	Code    int32                            `json:"code"`
	Status  string                           `json:"status"`
	Data    *PrivateForecastTimeResponseData `json:"data"`
	Errors  []interface{}                    `json:"errors,omitempty"`
}

type PrivateForecastTimeResponseData

type PrivateForecastTimeResponseData struct {
	ForecastTime float32 `json:"forecast_time"`
}

type PrivateTrendTabularResponse

type PrivateTrendTabularResponse struct {
	Success bool                             `json:"success"`
	Code    int32                            `json:"code"`
	Status  string                           `json:"status"`
	Data    *PrivateTrendTabularResponseData `json:"data"`
	Errors  []interface{}                    `json:"errors,omitempty"`
}

type PrivateTrendTabularResponseData

type PrivateTrendTabularResponseData struct {
	TrendTabular []PrivateTrendTabularResponseDataTrendTabular `json:"trend_tabular"`
}

type PrivateTrendTabularResponseDataTrendTabular

type PrivateTrendTabularResponseDataTrendTabular struct {
	Symbol string                         `json:"symbol"`
	Name   string                         `json:"name"`
	Trend  []PublicTrendResponseDataTrend `json:"trend"`
}

type PublicApiService

type PublicApiService service

func (*PublicApiService) V1PublicPriceChangeSymbolGet

func (a *PublicApiService) V1PublicPriceChangeSymbolGet(ctx context.Context, symbol string) (PublicPriceChangeResponse, *http.Response, error)

PublicApiService Price Change

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param symbol The cryptocurrency symbol.

@return PublicPriceChangeResponse

func (*PublicApiService) V1PublicPriceCurrentSymbolGet

func (a *PublicApiService) V1PublicPriceCurrentSymbolGet(ctx context.Context, symbol string) (PublicPriceCurrentResponse, *http.Response, error)

PublicApiService Price Current

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param symbol The cryptocurrency symbol, provide &#x60;all&#x60; to get every symbol.

@return PublicPriceCurrentResponse

func (*PublicApiService) V1PublicPriceHistorySymbolPeriodIntervalGet

func (a *PublicApiService) V1PublicPriceHistorySymbolPeriodIntervalGet(ctx context.Context, symbol string, period string, interval string) (PublicPriceHistoryResponse, *http.Response, error)

PublicApiService Price History

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param symbol The cryptocurrency symbol, provide &#x60;all&#x60; to get every symbol.
  • @param period The period to get data for, such as past 30 days.
  • @param interval The bar interval, such as 1 day.

@return PublicPriceHistoryResponse

func (*PublicApiService) V1PublicSummaryGet

func (a *PublicApiService) V1PublicSummaryGet(ctx context.Context) (PublicSummaryResponse, *http.Response, error)

PublicApiService Summary

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().

@return PublicSummaryResponse

func (*PublicApiService) V1PublicSymbolsGet

func (a *PublicApiService) V1PublicSymbolsGet(ctx context.Context) (PublicSymbolsResponse, *http.Response, error)

PublicApiService Symbols

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().

@return PublicSymbolsResponse

func (*PublicApiService) V1PublicTrendSymbolGet

func (a *PublicApiService) V1PublicTrendSymbolGet(ctx context.Context, symbol string) (PublicTrendResponse, *http.Response, error)

PublicApiService Trend The trend response contains a collection of forecasts for different intervals with the following attributes. + &#x60;time_start&#x60; start time of the period the forecast is applicable for + &#x60;time_end&#x60; end time of the period the forecast is applicable for + &#x60;interval&#x60; interval in hours that the forecast is applicable for + &#x60;weighted_price&#x60; forecasted weighted price during the period + &#x60;change_pct&#x60; percent change in price for forecasted weighted_price relative to current price + &#x60;change_usd&#x60; dollar change in price for forecasted weighted_price relative to current price

  • @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param symbol The cryptocurrency symbol.

@return PublicTrendResponse

type PublicPriceChangeResponse

type PublicPriceChangeResponse struct {
	Success bool                           `json:"success"`
	Code    int32                          `json:"code"`
	Status  string                         `json:"status"`
	Data    *PublicPriceChangeResponseData `json:"data"`
	Errors  []interface{}                  `json:"errors,omitempty"`
}

type PublicPriceChangeResponseData

type PublicPriceChangeResponseData struct {
	PriceChange []PublicPriceChangeResponseDataPriceChange `json:"price_change"`
}

type PublicPriceChangeResponseDataPriceChange

type PublicPriceChangeResponseDataPriceChange struct {
	Interval  string  `json:"interval"`
	ChangeUsd float32 `json:"change_usd"`
	ChangePct float32 `json:"change_pct"`
}

type PublicPriceCurrentResponse

type PublicPriceCurrentResponse struct {
	Success bool                            `json:"success"`
	Code    int32                           `json:"code"`
	Status  string                          `json:"status"`
	Data    *PublicPriceCurrentResponseData `json:"data"`
	Errors  []interface{}                   `json:"errors,omitempty"`
}

type PublicPriceCurrentResponseData

type PublicPriceCurrentResponseData struct {
	Current []PublicPriceCurrentResponseDataCurrent `json:"current"`
}

type PublicPriceCurrentResponseDataCurrent

type PublicPriceCurrentResponseDataCurrent struct {
	Symbol    string  `json:"symbol"`
	Name      string  `json:"name"`
	Price     float32 `json:"price"`
	ChangeUsd float32 `json:"change_usd"`
	ChangePct float32 `json:"change_pct"`
}

type PublicPriceHistoryResponse

type PublicPriceHistoryResponse struct {
	Success bool                            `json:"success"`
	Code    int32                           `json:"code"`
	Status  string                          `json:"status"`
	Data    *PublicPriceHistoryResponseData `json:"data"`
	Errors  []interface{}                   `json:"errors,omitempty"`
}

type PublicPriceHistoryResponseData

type PublicPriceHistoryResponseData struct {
	PriceHistory []PublicPriceHistoryResponseDataPriceHistory `json:"price_history"`
}

type PublicPriceHistoryResponseDataHistory

type PublicPriceHistoryResponseDataHistory struct {
	Time  float32 `json:"time"`
	Price float32 `json:"price"`
}

type PublicPriceHistoryResponseDataPriceHistory

type PublicPriceHistoryResponseDataPriceHistory struct {
	Symbol  string                                  `json:"symbol"`
	Name    string                                  `json:"name"`
	History []PublicPriceHistoryResponseDataHistory `json:"history"`
}

type PublicSummaryResponse

type PublicSummaryResponse struct {
	Success bool                        `json:"success"`
	Code    int32                       `json:"code"`
	Status  string                      `json:"status"`
	Data    []PublicSummaryResponseData `json:"data"`
	Errors  []interface{}               `json:"errors,omitempty"`
}

type PublicSummaryResponseColor

type PublicSummaryResponseColor struct {
	B float32 `json:"b"`
	G float32 `json:"g"`
	R float32 `json:"r"`
}

type PublicSummaryResponseData

type PublicSummaryResponseData struct {
	Icon           string                         `json:"icon"`
	Name           string                         `json:"name"`
	SymbolName     string                         `json:"symbol_name"`
	Slug           string                         `json:"slug"`
	Added          float32                        `json:"added"`
	Color          *PublicSummaryResponseColor    `json:"color"`
	PriceBtc       float32                        `json:"price_btc"`
	PriceUsd       float32                        `json:"price_usd"`
	MarketCap      float32                        `json:"market_cap"`
	VolumeUsd      float32                        `json:"volume_usd"`
	ChangePct      float32                        `json:"change_pct"`
	MarketDataTime float32                        `json:"market_data_time"`
	Trend          []PublicTrendResponseDataTrend `json:"trend"`
}

type PublicSymbolsResponse

type PublicSymbolsResponse struct {
	Success bool                       `json:"success"`
	Code    int32                      `json:"code"`
	Status  string                     `json:"status"`
	Data    *PublicSymbolsResponseData `json:"data"`
	Errors  []interface{}              `json:"errors,omitempty"`
}

type PublicSymbolsResponseData

type PublicSymbolsResponseData struct {
	Symbols []PublicSymbolsResponseDataSymbols `json:"symbols"`
}

type PublicSymbolsResponseDataSymbols

type PublicSymbolsResponseDataSymbols struct {
	Name   string `json:"name"`
	Symbol string `json:"symbol"`
}

type PublicTrendResponse

type PublicTrendResponse struct {
	Success bool                     `json:"success"`
	Code    int32                    `json:"code"`
	Status  string                   `json:"status"`
	Data    *PublicTrendResponseData `json:"data"`
	Errors  []interface{}            `json:"errors,omitempty"`
}

type PublicTrendResponseData

type PublicTrendResponseData struct {
	Trend []PublicTrendResponseDataTrend `json:"trend"`
}

type PublicTrendResponseDataTrend

type PublicTrendResponseDataTrend struct {
	TimeStart     float32 `json:"time_start"`
	TimeEnd       float32 `json:"time_end"`
	Interval      string  `json:"interval"`
	WeightedPrice float32 `json:"weighted_price"`
	ChangeUsd     float32 `json:"change_usd"`
	ChangePct     float32 `json:"change_pct"`
	Confidence    float32 `json:"confidence"`
}

type SummaryRoute

type SummaryRoute struct {
}

type SymbolsRoute

type SymbolsRoute struct {
}

type TrendRoute

type TrendRoute struct {
}

type TrendTabluarRoute

type TrendTabluarRoute struct {
}

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL