Docs & Resources

Everything you Need to Get Started with our APIs

Use Any Language

Clients for All Major Development Languages

Create your application in any language. No more C++/Java limitations. Use the technology you already know, and spend your time creating, not integrating.

1package main
2import (
3    "fmt"
4    websocket "github.com/gorilla/websocket"
5)
6
7const APIKEY = "YOUR_API_KEY"
8const CHANNELS = "C.AUD/USD,C.USD/EUR,C.USD/JPY"
9
10func main(){
11    c, _, err := websocket.DefaultDialer.Dial("wss://socket.polygon.io/forex", nil )
12    if err != nil {
13        panic( err )
14    }
15    defer c.Close()
16    c.WriteMessage( websocket.TextMessage, []byte( fmt.Sprintf("{\"action\":\"auth\",\"params\":\"%s\"}", APIKEY) ) )
17    c.WriteMessage( websocket.TextMessage, []byte( fmt.Sprintf("{\"action\":\"subscribe\",\"params\":\"%s\"}", CHANNELS) ) )
18    var msg interface{}
19    for {
20        err := c.ReadJSON( &msg ); if err != nil {
21            panic( err )
22        }
23        fmt.Println( "Message:", msg )
24    }
25}
26