Skip to content

Using the API

While the SDK is recommended, the API is an alternative way to get started with Stack.

Get Started

Get your API key

Sign up at stack.so/signup to get your API key and create a point system. You can continue to track your point system in the Stack dashboard.

Track an event

In the following examples, we are using pointSystemId = 3 but you can retrieve your point system ID from the Stack dashboard

cURL

shell
curl --request POST \
  --url https://track.stack.so/event \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <API_KEY>' \
  --data '{
	"name": "connect_spotify",
	"account": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
	"pointSystemId": 3
}'

Params

NameDescription
nameThe name of the event
accountThe address associated with event
pointSystemIdThe point system ID for this event
points (optional)The amount of points associated to this event, default 0
uniqueId (optional)Optional unique id to ensure event is only processed once (See SDK docs)
eventTimestamp (optional)Time when this event occurred (if not specified, this will be when the event is processed)
metadata (optional)Optional metadata to be saved with the event

Examples

Python

python
import requests

url = "https://track.stack.so/event"

payload = {
  "name": "connect_spotify",
  "account": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  "pointSystemId": 3
}
headers = {
  "Content-Type": "application/json",
  "x-api-key": "<API_KEY>"
}

response = requests.request("POST", url, json=payload, headers=headers)

Go

go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {
	url := "https://track.stack.so/event"
	payload := strings.NewReader("{\n\t\"name\": \"connect_spotify\",\n\t\"account\": \"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045\",\n\t\"pointSystemId\": 2560\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("x-api-key", "<API_KEY>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))
}

Fetching events

Docs coming soon!