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.

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
package main
import (
    "fmt"
    websocket "github.com/gorilla/websocket"
)

const APIKEY = "YOUR_API_KEY"
const CHANNELS = "C.AUD/USD,C.USD/EUR,C.USD/JPY"

func main(){
    c, _, err := websocket.DefaultDialer.Dial("wss://socket.polygon.io/forex", nil )
    if err != nil {
        panic( err )
    }
    defer c.Close()
    c.WriteMessage( websocket.TextMessage, []byte( fmt.Sprintf("{\"action\":\"auth\",\"params\":\"%s\"}", APIKEY) ) )
    c.WriteMessage( websocket.TextMessage, []byte( fmt.Sprintf("{\"action\":\"subscribe\",\"params\":\"%s\"}", CHANNELS) ) )
    var msg interface{}
    for {
        err := c.ReadJSON( &msg ); if err != nil {
            panic( err )
        }
        fmt.Println( "Message:", msg )
    }
}