Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tastytrade Open API Go Wrapper

Build

Go API wrapper for the Tastytrade Open API

Table of Contents

  1. Introduction
  2. Installation
  3. Authentication
  4. Usage
  5. Testing
  6. Contributing
  7. License

Introduction

This project provides a Go wrapper for the Tastytrade Open API. It allows developers to interact with Tastytrade's financial data and services in a more Go-idiomatic way, abstracting away the details of direct HTTP requests and responses.

Installation

To install this project, you can use go get:

go get github.com/optionsvamp/tastytrade

Then, import it in your Go code:

import "github.com/optionsvamp/tastytrade"

Authentication

The client supports two authentication methods.

Session (username/password)POST /sessions; token is sent as Bearer on subsequent requests:

api := tastytrade.NewTastytradeAPI()
err := api.Authenticate(os.Getenv("TT_USER"), os.Getenv("TT_PASSWORD"))

OAuth2 (recommended) — Use an OAuth client registered with Tastytrade. Obtain a refresh token via the Tastytrade UI, then pass it to AuthenticateOAuth2. Access tokens expire in 15 minutes; the client refreshes them automatically.

api := tastytrade.NewTastytradeAPI()
err := api.AuthenticateOAuth2(clientID, clientSecret, refreshToken)

All requests include the required User-Agent and Accept: application/json headers, and send the token as Authorization: Bearer <token>. Use SetAPIVersion("YYYYMMDD") to target a specific API version and SetUserAgent("my-app/1.0") to set the User-Agent.

Usage

Example: get account balances after authenticating:

api := tastytrade.NewTastytradeAPI()
_ = api.Authenticate(os.Getenv("TT_USER"), os.Getenv("TT_PASSWORD"))
balances, err := api.GetAccountBalances("your-account-number")
if err != nil {
    log.Fatal(err)
}
fmt.Println(balances)

Testing

To run the tests for this project, you can use go test:

go test ./...

Contributing

Contributions to this project are welcome! Please submit a pull request or open an issue on GitHub.

License

This project is released into the public domain under the Unlicense. For more information, please refer to the LICENSE file or visit https://unlicense.org.

About

Go API wrapper for the Tastytrade Open API

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages