-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
67 lines (67 loc) · 2 KB
/
Copy pathdoc.go
File metadata and controls
67 lines (67 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Package marketstack provides a comprehensive Go client for the Marketstack API.
//
// Marketstack is a REST API that provides real-time, intraday, and historical
// stock market data from 70+ global exchanges. This client library offers an
// idiomatic Go interface to interact with all Marketstack API endpoints.
//
// # Installation
//
// go get github.com/tigusigalpa/marketstack-go
//
// # Quick Start
//
// Create a new client and fetch end-of-day data:
//
// client := marketstack.NewClient("your-api-key", nil)
// eodData, err := client.GetEOD(context.Background(), &marketstack.EODOptions{
// Symbols: []string{"AAPL", "GOOG"},
// DateFrom: "2024-01-01",
// DateTo: "2024-01-31",
// Limit: 100,
// })
//
// # Authentication
//
// The API key can be provided in two ways:
//
// 1. Directly to the constructor:
//
// client := marketstack.NewClient("your-api-key", nil)
//
// 2. Via the MARKETSTACK_API_KEY environment variable:
//
// export MARKETSTACK_API_KEY="your-api-key"
// client := marketstack.NewClient("", nil)
//
// # Context Support
//
// All API methods accept a context.Context parameter for cancellation and timeouts:
//
// ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
// defer cancel()
// data, err := client.GetEOD(ctx, opts)
//
// # Error Handling
//
// API errors are returned as *APIError types:
//
// data, err := client.GetTicker(ctx, "INVALID")
// if err != nil {
// if apiErr, ok := err.(*marketstack.APIError); ok {
// fmt.Printf("API Error: %s - %s\n", apiErr.Code, apiErr.Message)
// }
// }
//
// # Available Endpoints
//
// The client supports all major Marketstack API endpoints:
//
// - End-of-Day Data: GetEOD, GetEODLatest, GetEODByDate
// - Intraday Data: GetIntraday, GetIntradayLatest
// - Tickers: GetTickers, GetTicker
// - Exchanges: GetExchanges, GetExchange
// - Currencies: GetCurrencies
// - Timezones: GetTimezones
//
// For complete documentation, visit: https://docs.apilayer.com/marketstack
package marketstack