Javascript SDK

This guide shows how to interact with the API using the JavaScript client.


Installation

npm install @fortisx/sdk

or

yarn add @fortisx/sdk

Initialization

Modern usage (ES Modules)

import { API } from "@fortisx/sdk"

const api = new API("YOUR_API_KEY")

Legacy usage (CommonJS)

const { API } = require("@fortisx/sdk")

const api = new API("YOUR_API_KEY")

Constructor options

Name
Type
Default
Description

apiKey

string

API key used for authorization

baseUrl

string

https://api.fortisx.fi/v1

Override if using a custom environment

timeout

number

10000

Request timeout in milliseconds


Methods

Method
Arguments
Returns
Description

get(endpoint, params?)

string, object?

Promise<object>

Performs a GET request

post(endpoint, data?)

string, object?

Promise<object>

Performs a POST request

put(endpoint, data?)

string, object?

Promise<object>

Performs a PUT request

delete(endpoint)

string

Promise<object>

Performs a DELETE request


Error Handling

All methods return a Promise. When a network or server error occurs, an exception of type APIError is thrown.

Field
Type
Description

message

string

Short description of the error

status

number

HTTP status code

details

object

Full response body if available

Example:


Example: /ping Endpoint

Last updated