Files
onspring-api-sdk-javascript/README.md
T

7.6 KiB

Onspring API Javascript SDK

lint_format_test codecov build_publish semantic-release: angular

The javascript SDK for the Onspring API is meant to simplify development in Javascript for Onspring customers who want to build integrations with their Onspring instance.

Note: This is an unofficial SDK for the Onspring API. It was not built in consultation with Onspring Technologies LLC or a member of their development team.

This SDK was developed independently using their existing C# SDK, their swagger page, and api documentation as the starting point with the intention of making development of integrations done in Javascript with an Onspring instance quicker and more convenient.

Dependencies

Node.js

Requires use of Node 14.x or later.

Axios

All methods for the OnspringClient make use of the Axios http client to interact with the Onspring API.

Form-Data

When it is necessary to send requests to the Onspring API using multi-part/form-data the Form-Data package is used.

Installation

Install the SDK using npm:

npm install onspring-api-sdk

API Key

In order to successfully interact with the Onspring Api you will need an API key. API keys are obtained by an Onspring user with permissions to at least Read API Keys for your instance via the following steps:

  1. Login to the Onspring instance.
  2. Navigate to Administration > Security > API Keys
  3. On the list page, add a new API Key - this will require Create permissions - or click an existing API key to view its details.
  4. Click on the Developer Information tab.
  5. Copy the X-ApiKey Header value from this tab.

Start Coding

OnspringClient

The most common way to use the SDK is to create an OnspringClient instance and call its methods. Its constructor requires two parameters:

  • baseUrl - currently this should always be: https://api.onspring.com
  • apiKey - the value obtained by following the steps in the API Key section

It is best practice to read these values in from a configuration file for both flexibility and security purposes.

Example .env file:

API_KEY=000000ffffff000000ffffff/00000000-ffff-0000-ffff-000000000000
BASE_URL=https://api.onspring.com

Example constructing OnspringClient:

CommonJS


ES Module


ApiResponse

Each OnspringClient method - aside from canConnect - returns an ApiResponse object which will have the following properties:

  • statusCode - The http status code of the response.
  • isSuccessful - Indicates whether the request succeeded.
  • data - If the request was successful will contain the response data deserialized to custom classes.
  • message - A message that may provide more detail about the request when no successful

CommonJS or ES Modules

There is support for using either CommonJS or ES Modules depending upon your preference. This documentation will use the later in the usage examples.

Types

The package is written in typescript and all types are exported and availabe for you to use if you prefer to use typescript.

Full API Documentation

You may wish to refer to the full Onspring API documentation when determining which values to pass as parameters to some of the OnspringClient methods. There is also a swagger page that you can use for making exploratory requests.

Connectivity

Verify connectivity


Apps

Get Apps

Returns a paged collection of apps and/or surveys that can be paged through. By default the page size is 50 and page number is 1.


You can set your own page size and page number (max is 1,000) as well.


Get App By Id

Returns an Onspring app or survey according to provided id.


Get Apps By Ids

Returns a collection of Onspring apps and/or surveys according to provided ids.


Fields

Get Field By Id

Returns an Onspring field according to provided id.


Get Fields By Ids

Returns a collection of Onspring fields according to provided ids.


Get Fields By App Id

Returns a paged collection of fields that can be paged through. By default the page size is 50 and page number is 1.


You can set your own page size and page number (max is 1,000) as well.


Files

Get File Info By Id

Returns the Onspring file's metadata.


Get File By Id

Returns the file itself.


Save File


Delete File By Id


Lists

Add Or Update List Value

To add a list value don't provide an id value.


To update a list value provide an id value.


Delete List Value


Records

Get Records By App Id

Returns a paged colletion of records that can be paged through. By default the page size is 50 and page number is 1.


You can set your own page size and page number (max is 1,000) as well. In addition to specifying what field values to return and in what format (Raw vs. Formatted) to return them.


Get Record By Id

Returns an onspring record based on the provided app and record ids.


You can also specify what field values to return and in what format (Raw vs. Formatted) to return them.


Get Records By Ids

Returns a collection of Onspring records based on the provided appId and recordIds.


You can also specify what field values to return and in what format (Raw vs. Formatted) to return them.


Query Records

Returns a paged colletion of records based on a criteria that can be paged through. By default the page size is 50 and page number is 1.


You can set your own page size and page number (max is 1,000) as well. In addition to specifying what field values to return and in what format (Raw vs. Formatted) to return them.


For further details on constructing the filter parameter please refer to the documentation for v2 of the Onspring API.

Add or Update A Record

You can add a record by not providing a record id value. If successful will return the id of the added record.


You can update a record by providing its id. If successful will return the id of record updated.


Delete Records By Ids


Reports

Get Report By Id

Returns the report for the provided id.


You can also specify the format of the data in the report as well as whether you are requesting the report's data or its chart data.


Get Reports By App Id

Returns a paged collection of reports that can be paged through. By default the page size is 50 and page number is 1.