Go SDK

This guide explains how to interact with the API using the Go client.


Installation

go get github.com/fortisx/go-sdk

Initialization

package main

import (
    "fmt"
    "log"

    api "github.com/fortisx/go-sdk"
)

func main() {
    client := api.NewAPI("YOUR_API_KEY")

    res, err := client.Get("ping", nil)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(res)
}

Constructor

Defaults:

  • Base URL: https://api.fortisx.fi/v1

  • Timeout: 10 seconds

Optional setters:


Methods

Method
Signature
Description

Get

Get(endpoint string, params map[string]string) (map[string]interface{}, error)

Performs a GET request

Post

Post(endpoint string, data map[string]interface{}) (map[string]interface{}, error)

Performs a POST request

Put

Put(endpoint string, data map[string]interface{}) (map[string]interface{}, error)

Performs a PUT request

Delete

Delete(endpoint string) (map[string]interface{}, error)

Performs a DELETE request

All methods automatically include the following headers:


Error Handling

When a request fails, an APIError is returned. This struct implements the error interface.

Example:


Example: /ping Endpoint

Last updated