Documentation
¶
Overview ¶
Package api includes the HTTP client used to access the REST JSON API.
Information about specific endpoints and their parameters can be found at: https://api.test.nordnet.se/api-docs/index.html
Index ¶
- Variables
- type APIClient
- func (c *APIClient) Account(accountno int64) (res *models.AccountInfo, err error)
- func (c *APIClient) AccountLedgers(accountno int64) (res []models.LedgerInformation, err error)
- func (c *APIClient) AccountOrders(accountno int64, params *Params) (res []models.Order, err error)
- func (c *APIClient) AccountPositions(accountno int64) (res []models.Position, err error)
- func (c *APIClient) AccountTrades(accountno int64, params *Params) (res []models.Trade, err error)
- func (c *APIClient) Accounts() (res []models.Account, err error)
- func (c *APIClient) ActivateOrder(accountno int64, orderId int64) (res *models.OrderReply, err error)
- func (c *APIClient) Countries() (res []models.Country, err error)
- func (c *APIClient) CreateOrder(accountno int64, req *CreateOrderRequest) (res *models.OrderReply, err error)
- func (c *APIClient) DeleteOrder(accountno int64, orderId int64) (res *models.OrderReply, err error)
- func (c *APIClient) Indicators() (res []models.Indicator, err error)
- func (c *APIClient) InstrumentLeverageFilters(id int64, params *Params) (res *models.LeverageFilter, err error)
- func (c *APIClient) InstrumentLeverages(id int64, params *Params) (res []models.Instrument, err error)
- func (c *APIClient) InstrumentLookup(lookupType string, lookup string) (res []models.Instrument, err error)
- func (c *APIClient) InstrumentOptionPairFilters(id int64, params *Params) (res *models.OptionPairFilter, err error)
- func (c *APIClient) InstrumentOptionPairs(id int64, params *Params) (res []models.OptionPair, err error)
- func (c *APIClient) InstrumentSector(sectors string) (res []models.Sector, err error)
- func (c *APIClient) InstrumentSectors(params *Params) (res []models.Sector, err error)
- func (c *APIClient) InstrumentType(instrumentType string) (res []models.InstrumentType, err error)
- func (c *APIClient) InstrumentTypes() (res []models.InstrumentType, err error)
- func (c *APIClient) InstrumentUnderlyings(derivateType string, currency string) (res []models.Instrument, err error)
- func (c *APIClient) Instruments(ids string) (res []models.Instrument, err error)
- func (c *APIClient) List(id int64) (res []models.Instrument, err error)
- func (c *APIClient) Lists() (res []models.List, err error)
- func (c *APIClient) Login() (res *models.Login, err error)
- func (c *APIClient) Logout() (res *models.LoggedInStatus, err error)
- func (c *APIClient) LookupCountries(countries string) (res []models.Country, err error)
- func (c *APIClient) LookupIndicators(indicators string) (res []models.Indicator, err error)
- func (c *APIClient) Market(ids string) (res []models.Market, err error)
- func (c *APIClient) Markets() (res []models.Market, err error)
- func (c *APIClient) News(ids string) (res []models.NewsItem, err error)
- func (c *APIClient) NewsSources() (res []models.NewsSource, err error)
- func (c *APIClient) Perform(method, path string, params *Params, res interface{}) error
- func (c *APIClient) PerformContext(ctx context.Context, method, path string, params *Params, res interface{}) error
- func (c *APIClient) RealtimeAccess() (res []models.RealtimeAccess, err error)
- func (c *APIClient) SearchInstruments(params *Params) (res []models.Instrument, err error)
- func (c *APIClient) SearchNews(params *Params) (res []models.NewsPreview, err error)
- func (c *APIClient) SetContext(ctx context.Context)
- func (c *APIClient) SetRetryConfig(cfg RetryConfig)
- func (c *APIClient) SystemStatus() (res *models.SystemStatus, err error)
- func (c *APIClient) TickSize(ids string) (res []models.TicksizeTable, err error)
- func (c *APIClient) TickSizes() (res []models.TicksizeTable, err error)
- func (c *APIClient) Touch() (res *models.LoggedInStatus, err error)
- func (c *APIClient) TradableInfo(ids string) (res []models.TradableInfo, err error)
- func (c *APIClient) TradableIntraday(ids string) (res []models.IntradayGraph, err error)
- func (c *APIClient) TradableTrades(ids string) (res []models.PublicTrades, err error)
- func (c *APIClient) UpdateOrder(accountno int64, orderId int64, req *UpdateOrderRequest) (res *models.OrderReply, err error)
- type APIError
- type APIHTTPError
- type CreateOrderRequest
- type LoginRequest
- type Params
- type RateLimitError
- type RetryConfig
- type UpdateOrderRequest
Constants ¶
This section is empty.
Variables ¶
var TooManyRequestsError = errors.New("Too Many Requests, please wait for 10 seconds before trying again")
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient struct {
URL, Service, Version, Credentials, SessionKey string
ExpiresAt, LastUsageAt time.Time
http.Client
sync.RWMutex
// contains filtered or unexported fields
}
APIClient provides all API-endpoints available as methods.
func NewAPIClient ¶
Constructor function takes the credentials string produced by the util package.
func NewAPIClientWithBaseURL ¶
Constructor function for creating a client pointing at a custom base URL.
func NewAPITestClient ¶
Constructor function for creating a client pointing to the NEXT test environment.
func (*APIClient) Account ¶
func (c *APIClient) Account(accountno int64) (res *models.AccountInfo, err error)
The account summary gives details of the account.
func (*APIClient) AccountLedgers ¶
func (c *APIClient) AccountLedgers(accountno int64) (res []models.LedgerInformation, err error)
Information about the currency ledgers of an account.
func (*APIClient) AccountOrders ¶
Get all orders beloning to an account.
func (*APIClient) AccountPositions ¶
Returns a list of all positions of the account.
func (*APIClient) AccountTrades ¶
Get all trades belonging to an account.
func (*APIClient) ActivateOrder ¶
func (c *APIClient) ActivateOrder(accountno int64, orderId int64) (res *models.OrderReply, err error)
Activate an inactive order. Please note that it is not possible to deactivate an order. The order must be entered as inactive.
func (*APIClient) Countries ¶
Get a list of all countries in the system. Please note that trading is not available everywhere.
func (*APIClient) CreateOrder ¶
func (c *APIClient) CreateOrder(accountno int64, req *CreateOrderRequest) (res *models.OrderReply, err error)
Enter a new order, market_id + identifier is the identifier of the tradable.
func (*APIClient) DeleteOrder ¶
Delete an order.
func (*APIClient) Indicators ¶
Returns a list indicators that the user has access to.
func (*APIClient) InstrumentLeverageFilters ¶
func (c *APIClient) InstrumentLeverageFilters(id int64, params *Params) (res *models.LeverageFilter, err error)
Returns valid filter values. Can be used to fill comboboxes in clients to filter leverages results. The same filters can be applied on this request to exclude invalid filter combinations.
func (*APIClient) InstrumentLeverages ¶
func (c *APIClient) InstrumentLeverages(id int64, params *Params) (res []models.Instrument, err error)
Returns a list of leverage instruments that have the current instrument as underlying. Leverage instruments is for example warrants and ETF:s. To get all valid filters for the current underlying please use "Get leverages filters". The filters can be used to narrow the search. If "Get leverages filters" is used to fill comboboxes the same filters can be applied on the that call to hide filter cominations that are not valid. Multiple filters can be applied.
func (*APIClient) InstrumentLookup ¶
func (c *APIClient) InstrumentLookup(lookupType string, lookup string) (res []models.Instrument, err error)
Lookup specific instrument with prededfined fields. Please note that this is not a search, only exact matches is returned.
func (*APIClient) InstrumentOptionPairFilters ¶
func (c *APIClient) InstrumentOptionPairFilters(id int64, params *Params) (res *models.OptionPairFilter, err error)
Returns valid filter values. Can be used to fill comboboxes in clients to filter options pair results. The same filters can be applied on this request to exclude invalid filter combinations.
func (*APIClient) InstrumentOptionPairs ¶
func (c *APIClient) InstrumentOptionPairs(id int64, params *Params) (res []models.OptionPair, err error)
Returns a list of call/put option pairs. They are balanced on strike price. In order to find underlyings with options use "Get underlyings". To get available expiration dates use "Get option pair filters".
func (*APIClient) InstrumentSector ¶
Get one or more sectors
func (*APIClient) InstrumentSectors ¶
Get all instrument sectors or the ones matching the group crtieria
func (*APIClient) InstrumentType ¶
func (c *APIClient) InstrumentType(instrumentType string) (res []models.InstrumentType, err error)
Get info of one orde more instrument type.
func (*APIClient) InstrumentTypes ¶
func (c *APIClient) InstrumentTypes() (res []models.InstrumentType, err error)
Get all instrument types. Please note that these types is used for both instrument_type and instrument_group_type.
func (*APIClient) InstrumentUnderlyings ¶
func (c *APIClient) InstrumentUnderlyings(derivateType string, currency string) (res []models.Instrument, err error)
Get instruments that are underlyings for a specific type of instruments. The query can return instrument that have option derivatives or leverage derivatives. Warrants are included in the leverage derivatives.
func (*APIClient) Instruments ¶
func (c *APIClient) Instruments(ids string) (res []models.Instrument, err error)
Get one or more instruments, the instrument id is used as key
func (*APIClient) List ¶
func (c *APIClient) List(id int64) (res []models.Instrument, err error)
Get all instruments in a list.
func (*APIClient) Login ¶
Before any other of the services (except for the system info request) can be called the user must login. The username, password and phrase must be sent encrypted. TODO: move the params into function arguments since its only used here?
func (*APIClient) Logout ¶
func (c *APIClient) Logout() (res *models.LoggedInStatus, err error)
Invalidates the session.
func (*APIClient) LookupCountries ¶
Lookup one or more countries by country code. Multiple countries can be queried at the same time by comma separating the country codes.
func (*APIClient) LookupIndicators ¶
Returns info of one or more indicators. TODO: Merge with Indicators call above?
func (*APIClient) Market ¶
Lookup one or more markets by market_id. Multiple market can be queried at the same time by comma separating the market_ids. Market 80 is the smart order market. Instruments that can be traded on 2 or more markets gets a tradable on the smart order market. Orders entered with the smart order tradable get smart order routed with the current Nordnet best execution policy.
func (*APIClient) Markets ¶
Get all tradable markets. Market 80 is the smart order market. Instruments that can be traded on 2 or more markets gets a tradable on the smart order market. Orders entered with the smart order tradable get smart order routed with the current Nordnet best execution policy.
func (*APIClient) News ¶
Show one or more news items. Search for news. If no search field is used the last news available to the user is returned.
func (*APIClient) NewsSources ¶
func (c *APIClient) NewsSources() (res []models.NewsSource, err error)
Returns a list of news sources the user has access to
func (*APIClient) PerformContext ¶
func (*APIClient) RealtimeAccess ¶
func (c *APIClient) RealtimeAccess() (res []models.RealtimeAccess, err error)
Get realtime data access. This applies to the access on the feeds. If the market is missing the user don't have realtime access on that market.
func (*APIClient) SearchInstruments ¶
func (c *APIClient) SearchInstruments(params *Params) (res []models.Instrument, err error)
Free text search. A list of instruments is returned.
func (*APIClient) SearchNews ¶
func (c *APIClient) SearchNews(params *Params) (res []models.NewsPreview, err error)
Search for news. If no search field is used the last news available to the user is returned.
func (*APIClient) SetContext ¶
func (*APIClient) SetRetryConfig ¶
func (c *APIClient) SetRetryConfig(cfg RetryConfig)
func (*APIClient) SystemStatus ¶
func (c *APIClient) SystemStatus() (res *models.SystemStatus, err error)
Information about the system status can be retrieved by this HTTP request. This is the only service that can be called without authentication.
func (*APIClient) TickSize ¶
func (c *APIClient) TickSize(ids string) (res []models.TicksizeTable, err error)
Get one or more ticksize tables.
func (*APIClient) TickSizes ¶
func (c *APIClient) TickSizes() (res []models.TicksizeTable, err error)
Get all ticksize tables.
func (*APIClient) Touch ¶
func (c *APIClient) Touch() (res *models.LoggedInStatus, err error)
If the application needs to keep the session alive the session can be touched. Note the basic auth header field must be set as for all other calls. All calls to any REST service is touching the session. So touching the session manually is only needed if no other calls are done during the session timeout interval.
func (*APIClient) TradableInfo ¶
func (c *APIClient) TradableInfo(ids string) (res []models.TradableInfo, err error)
Get trading calender and allowed trading types for one or more tradable.
func (*APIClient) TradableIntraday ¶
func (c *APIClient) TradableIntraday(ids string) (res []models.IntradayGraph, err error)
Can be used for populating instrument price graphs for today. Resolution is one minute.
func (*APIClient) TradableTrades ¶
func (c *APIClient) TradableTrades(ids string) (res []models.PublicTrades, err error)
Get all public trades (all trades done on the marketplace) beloning to one ore more tradable.
func (*APIClient) UpdateOrder ¶
func (c *APIClient) UpdateOrder(accountno int64, orderId int64, req *UpdateOrderRequest) (res *models.OrderReply, err error)
Modify price and or volume on an order.
type APIHTTPError ¶
func (APIHTTPError) Error ¶
func (e APIHTTPError) Error() string
type CreateOrderRequest ¶
type CreateOrderRequest struct {
Identifier string
MarketID string
Price string
Side string
Volume string
Currency string
Extras Params
}
CreateOrderRequest represents form fields for order creation. Extras can be used for optional fields not modeled explicitly.
type LoginRequest ¶
type RateLimitError ¶
func (RateLimitError) Error ¶
func (e RateLimitError) Error() string
func (RateLimitError) Unwrap ¶
func (e RateLimitError) Unwrap() error