The status code of the response.
+The message of the response.
+The data of the response.
+asAppCollectionType - Converts the ApiResponse to an ApiResponse<CollectionResponse
asAppType - Converts the ApiResponse to an ApiResponse
asCreatedWithIdResponseType - Converts the ApiResponse to an ApiResponse<CreatedWithIdResponse
asFieldCollectionType - Converts the ApiResponse to an ApiResponse<CollectionResponse
asFieldType - Converts the ApiResponse to an ApiResponse
asFileInfoType - Converts the ApiResponse to an ApiResponse
asFileType - Converts the ApiResponse to an ApiResponse
asGetPagedAppsResponseType - Converts the ApiResponse to an ApiResponse
asGetPagedFieldsResponseType - Converts the ApiResponse to an ApiResponse
asGetPagedRecordsResponseType - Converts the ApiResponse to an ApiResponse
asGetPagedReportsResponseType - Converts the ApiResponse to an ApiResponse
asListItemResponseType - Converts the ApiResponse to an ApiResponse
asRecordCollectionType - Converts the ApiResponse to an ApiResponse<CollectionResponse
asRecordType - Converts the ApiResponse to an ApiResponse
asReportDataType - Converts the ApiResponse to an ApiResponse
asSaveRecordResponseType - Converts the ApiResponse to an ApiResponse
Static Private convertThe attachment item to convert.
+convertToAttachment - Converts the attachment item to the appropriate attachment object.
+Static Private convertStatic Private convertThe scoring group item to convert.
+convertToScoringGroup - Converts the scoring group item to the appropriate scoring group object.
+Static Private convertThe time span item to convert.
+convertToTimeSpanData - Converts the time span item to the appropriate time span data object.
+Static Private getStatic Private getStatic Private getThe record value item.
+getRecordValueByType - Gets the RecordValue by by type.
+Generated using TypeDoc
Generated using TypeDoc
Attachment - Represents an attachment.
+The id of the file.
+The name of the file.
+The notes associated with the file.
+The storage location of the file.
+Generated using TypeDoc
AttachmentListRecordValue - A record value represented by a list of attachments.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
CollectionResponse - A generic object for responses that contain collections of objects.
+The total count of items in the collection.
+The items in the collection.
+Generated using TypeDoc
CreatedWithIdResponse
The id of the created object.
+Generated using TypeDoc
DateRecordValue - A value for a date field in a record.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
DecimalRecordValue - Represents a decimal record value
+The id of the field
+The value of the field
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
Delegate - Represents a delegate.
+The type of delegate.
+The name of the delegate.
+The email address of the delegate.
+The date and time the delegate was assigned.
+The date and time the delegate completed the survey.
+Generated using TypeDoc
DelegateListRecordValue - Represents a delegate list record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
EndpointFactory - A factory class for creating endpoints.
+Static getStatic getStatic getStatic getStatic getStatic getThe id of the record.
+The id of the field.
+The id of the file.
+getDeleteFileByIdEndpoint - Gets the delete file by id endpoint.
+Static getStatic getStatic getStatic getStatic getStatic getStatic getStatic getStatic getStatic getStatic getStatic getStatic getStatic getStatic getStatic getGenerated using TypeDoc
Field - Represents a Field.
+The id of the Field.
+The id of the App that the Field belongs to.
+The name of the Field.
+The type of the Field.
+The status of the Field.
+Indicates whether or not the Field is required.
+Indicates whether or not the Field is required to be unique.
+Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
FileListRecordValue - Represents a file list record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
FormulaField - Represents a formula field.
+The id of the formula field.
+The id of the app the formula field belongs to.
+The name of the formula field.
+The type of the formula field.
+The status of the formula field.
+Whether the formula field is required.
+Whether the formula field is unique.
+The output type of the formula field.
+The list values of the formula field.
+Generated using TypeDoc
GetPagedAppsResponse - A paged response model for the GetApps method.
+The items in the collection.
+The page number of the response.
+The page size of the response.
+The total number of pages in the response.
+The total number of records in the response.
+Generated using TypeDoc
GetPagedFieldsResponse - A response containing a paged collection of fields.
+The items in the collection.
+The page number of the response.
+The page size of the response.
+The total number of pages in the response.
+The total number of records in the response.
+Generated using TypeDoc
GetPagedRecordsResponse - A response containing a paged collection of records.
+The items in the collection.
+The page number of the response.
+The page size of the response.
+The total number of pages in the response.
+The total number of records in the response.
+Generated using TypeDoc
GetPagedReportsResponse - Represents a response containing a paged list of reports.
+The list of reports.
+The page number.
+The page size.
+The total number of pages.
+The total number of records.
+Generated using TypeDoc
GetRecordRequest - A request to get a record.
+The id of the app that the record belongs to.
+The id of the record.
+The ids of the fields to include in the response.
+The format of the data in the response.
+Generated using TypeDoc
GetRecordsByAppIdRequest - Represents a request to get records by app id.
+The id of the app that the records belong to.
+The ids of the fields to include in the response.
+The format of the data in the response.
+The paging request.
+Generated using TypeDoc
GetRecordsRequest - Request to get records by their ids
+The id of the app the records belong to.
+The ids of the records to get.
+The ids of the fields to include in the response.
+The format of the data in the response.
+Generated using TypeDoc
GuidListRecordValue - Represents a guid list record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
GuidRecordValue - Represents a guid record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
IntegerListRecordValue - Represents an integer list record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
IntegerRecordValue - A record value represented by an integer.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
ListField - Represents a list field.
+The id of the list field.
+The id of the app the list field belongs to.
+The name of the list field.
+The type of the list field.
+The status of the list field.
+Whether the list field is required.
+Whether the list field is unique.
+The multiplicity of the list field.
+The id of the list the list field belongs to.
+The list values of the list field.
+Generated using TypeDoc
ListItemRequest - Represents a list item request
+The id for the list that the item belongs to.
+The id for the list item.
+The name of the list item.
+The numeric value of the list item.
+The color of the list item.
+Generated using TypeDoc
ListItemResponse - Represents a respons when a list item is created or updated.
+The id of the list item.
+Generated using TypeDoc
ListValue - Represents a list value.
+The id of the list value.
+The name of the list value.
+The sort order of the list value.
+The numeric value of the list value.
+The color of the list value.
+Generated using TypeDoc
OnspringClient - A client that can communicate with the Onspring API.
+The base url that will be used to make requests to the Onspring API.
+The api key that will be used to authorize requests made by this client.
+Private Readonly _clientclient - The axios instance that will be used to make requests to the Onspring API.
+The request that will be used to add or update the list item.
+addOrUpdateListItem - Adds or updates a list item depending on if an id is provided or not.
+Private deleteThe endpoint that will be used to make the request.
+The configuration that will be used to make the request.
+delete - Makes a DELETE request to the specified endpoint.
+The id of the record that the file is held on.
+The id of the field that the file is held in.
+The id of the file to delete.
+deleteFileById - Deletes a file by its id.
+The id of the list that the list item belongs to.
+The id of the list item to delete.
+deleteListItemById - Deletes a list item by its id.
+The id of the app that the record belongs to.
+The id of the record to delete.
+deleteRecordById - Deletes a record by its id.
+The id of the app that the records belong to.
+The ids of the records to delete.
+deleteRecordsByIds - Deletes records by their ids.
+Private getThe endpoint that will be used to make the request.
+The configuration that will be used to make the request.
+get - Makes a GET request to the specified endpoint.
+The id of the app to get.
+getAppById - Gets an app by its id.
+The paging request that will be used to get the apps.
+getApps - Gets a paged list of apps.
+The ids of the apps to get.
+getAppsByIds - Gets a list of apps by their ids.
+The id of the field to get.
+getFieldById - Gets a field by its id.
+The id of the app to get the fields for.
+The paging request that will be used to get the fields.
+getFieldsByAppId - Gets a paged list of fields by an app id.
+The ids of the fields to get.
+getFieldsByIds - Gets a list of fields by their ids.
+The id of the record that the file is attached to.
+The id of the field that the file is attached to.
+The id of the file to get.
+getFileById - Gets a file by its id.
+The id of the record that the file is attached to.
+The id of the field that the file is attached to.
+The id of the file to get the information for.
+getFileInfoById - Gets a file's information by its id.
+The request that will be used to get the record.
+getRecordById - Gets a record by its id.
+The request that will be used to get the records.
+getRecordsByAppId - Gets records by an app id.
+The request that will be used to get the records.
+getRecordsByIds - Gets records by their ids.
+The id of the report to get.
+The data format that the report data will be returned in.
+The type of data that will be returned.
+getReportById - Gets a report by its id.
+The id of the app to get the reports for.
+The paging request that will be used to get the reports.
+getReportsByAppId - Gets a paged list of reports by the app id.
+Private postThe endpoint that will be used to make the request.
+The data that will be sent with the request.
+The configuration that will be used to make the request.
+post - Makes a POST request to the specified endpoint.
+Private putThe endpoint that will be used to make the request.
+The data that will be sent with the request.
+The configuration that will be used to make the request.
+put - Makes a PUT request to the specified endpoint.
+The request that will be used to query for records.
+getRecordsByQuery - Gets records by a query.
+The request that will be used to save the file.
+saveFile - Saves a file to a record in Onspring.
+The record or request that will be used to save the record.
+saveRecord - Saves a record.
+Generated using TypeDoc
PagedResponse - A generic paged response model
+The items in the collection.
+The page number of the response.
+The page size of the response.
+The total number of pages in the response.
+The total number of records in the response.
+Generated using TypeDoc
PagingRequest - Paging request model
+The page number of the request. Must be greater than 0.
+The page size of the request. Must be greater than 0 and less than 1001.
+Generated using TypeDoc
QueryFilter - Represents a query filter.
+The id of the field to filter on.
+The operator for the filter.
+The value for the filter.
+Generated using TypeDoc
QueryRecordsRequest - Request to query for records.
+The id of the app the records belong to.
+The filter to use to query for records.
+The ids of the fields to include in the response.
+The format of the data in the response.
+The paging request to use to query for records.
+Generated using TypeDoc
Record - A record in an app.
+The id of the app that the record belongs to.
+The id of the record.
+The data for the fields in the record.
+The value to add to the record.
+addValue - Adds a value to the record.
+The values to add to the record.
+addValues - Adds values to the record.
+convertToSaveRecordRequest - Converts the record to a SaveRecordRequest.
+Generated using TypeDoc
RecordValue - A value for a field in a record.
+The type of the record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Private validateThe expected types.
+validateType - Validates the type of the field value.
+Generated using TypeDoc
ReferenceField - Represents a reference field.
+The id of the reference field.
+The id of the app the reference field belongs to.
+The name of the reference field.
+The type of the reference field.
+The status of the reference field.
+Whether the reference field is required.
+Whether the reference field is unique.
+The multiplicity of the reference field.
+The id of the app the reference field references.
+Generated using TypeDoc
Generated using TypeDoc
ReportData - Represents the data for a report.
+The columns in the report.
+The rows in the report.
+Generated using TypeDoc
Generated using TypeDoc
SaveFileRequest - Represents a request to save a file.
+The id of the record that the file will be saved to.
+The id of the field that the file will be saved to.
+The notes for the file.
+The modified date for the file.
+The name of the file.
+The content type of the file.
+The file stream.
+Generated using TypeDoc
The key is the field id and the value is the value for the field.
+If the record id is not provided a new record will be created. Otherwise, the existing record will be updated.
+Generated using TypeDoc
SaveRecordResponse - Response from saving a record
+The id of the record.
+The warnings from saving the record.
+Generated using TypeDoc
ScoringGroup - A class that represents a scoring group.
+The id of the list value.
+The name of the scoring group.
+The score of the scoring group.
+The maximum score of the scoring group.
+Generated using TypeDoc
ScoringGroupListRecordValue - Represents a scoring group list record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
StringListRecordValue - Represents a string list record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
StringRecordValue - A record value represented by a string.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
The quantity of the time span.
+The increment of the time span.
+The recurrence of the time span.
+The number of occurrences of the time span.
+The end date of the time span.
+Generated using TypeDoc
TimeSpanRecordValue - Represents a time span record value.
+The id of the field.
+The value of the field.
+asAttachmentArray - Gets the value as an array of attachments.
+asScoringGroupArray - Gets the value as an array of scoring groups.
+asTimeSpanData - Gets the value as a TimeSpanData object.
+Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
FieldType - The type of field.
+Attachment - The field is a attachment field.
+AutoNumber - The field is a autonumber field.
+Date - The field is a date field.
+Formula - The field is a formula field.
+Image - The field is a image field.
+List - The field is a list field.
+Number - The field is a number field.
+Reference - The field is a reference field.
+SurveyCampaign - The field is a survey campaign field.
+SurveyDelegation - The field is a survey delegation field.
+SurveyGroupScoring - The field is a survey group scoring field.
+SurveyReference - The field is a survey reference field.
+SurveyUnifiedAnswer - The field is a survey unified answer field.
+Text - The field is a text field.
+TimeSpan - The field is a timespan field.
+Generated using TypeDoc
FileStorageSite - The site where the file is stored.
+GoogleDrive - The file is stored in Google Drive.
+Internal - The file is stored in the internal file storage.
+OneDrive - The file is stored in OneDrive.
+Generated using TypeDoc
FilterOperators - The operators that can be used in a query filter
+And - The and operator
+Can be used to create compound filters.
+Contains - The contains operator
+Can be used with list fields as well as their formula equivalents.
+Equal - The equal operator
+Can be used with text, auto-number, date, and number fields as well as their formula equivalents.
+GreaterThan - The greater than operator
+Can be used with auto-number, date, and number fields as well as their formula equivalents.
+IsNull - The is null operator
+Can be used with text, date, and number fields as well as their formula equivalents.
+LessThan - The less than operator
+Can be used with auto-number, date, and number fields as well as their formula equivalents.
+Not - The not operator
+Can be used to negate a filter and create compound filters.
+NotEqual - The not equal operator
+Can be used with text, auto-number, date, and number fields as well as their formula equivalents.
+NotNull - The not null operator
+Can be used with text, date, and number fields as well as their formula equivalents.
+Or - The or operator
+Can be used to create compound filters.
+Generated using TypeDoc
FormulaOutputType - The type of the formula output.
+DateAndTime - The formula output is a date and time value.
+ListValue - The formula output is a list value.
+Numeric - The formula output is a numeric value.
+Text - The formula output is a text value.
+Generated using TypeDoc
HttpStatusCode - Enum for HTTP status codes
+Accepted - The request was accepted for processing.
+BadGateway - The server received an invalid response from an upstream server.
+BadRequest - The request was invalid.
+Conflict - The request could not be completed due to a conflict with the current state of the resource.
+Created - The request was successful and a new resource was created.
+Forbidden - The request included an authentication token but the token was not valid.
+GatewayTimeout - The server did not receive a response from an upstream server in a timely manner.
+InternalServerError - An unexpected error occurred on the server.
+MethodNotAllowed - The requested method is not supported for the resource.
+NoContent - The request was successful but there is no content to return.
+NotFound - The requested resource does not exist.
+NotImplemented - The requested method is not implemented.
+OK - The request was successful.
+ServiceUnavailable - The server is currently unavailable.
+Unauthorized - The request did not include an authentication token.
+Generated using TypeDoc
Multiplicity - The multiplicity type of the object.
+MultiSelect - Multi select multiplicity.
+SingleSelect - Single select multiplicity.
+Generated using TypeDoc
RecordValueType - The type of the record value.
+AttachmentList - The record value is a list of attachments.
+Date - The record value is a Date.
+Decimal - The record value is a decimal.
+DelegateList - The record value is a list of delegates.
+FileList - The record value is a list of files.
+Guid - The record value is a Guid.
+GuidList - The record value is a list of Guids.
+Integer - The record value is an integer.
+IntegerList - The record value is a list of integers.
+ScoringGroupList - The record value is a list of scoring groups.
+String - The record value is a string.
+StringList - The record value is a list of strings.
+TimeSpan - The record value is a TimeSpan.
+Generated using TypeDoc
Generated using TypeDoc
TimeSpanIncrement - The increment values for a time span field.
+Days - The time span increment is days.
+Hours - The time span increment is hours.
+Minutes - The time span increment is minutes.
+Months - The time span increment is months.
+Seconds - The time span increment is seconds.
+Weeks - The time span increment is weeks.
+Years - The time span increment is years.
+Generated using TypeDoc
TimeSpanRecurrenceType - The type of recurrence for a time span.
+EndAfterOccurrences - The time span recurs for a specific number of occurrences.
+EndByDate - The time span recurs until a specific date.
+None - The time span does not recur.
+Generated using TypeDoc
Generated using TypeDoc
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 Onspring's existing C# SDK, the Onspring API's 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.
+Requires use of Node.js 14.x or later.
+All methods for the OnspringClient make use of the Axios http client to interact with the Onspring API.
When it is necessary to send requests to the Onspring API using multi-part/form-data the Form-Data package is used.
Install the SDK using npm:
+npm install onspring-api-sdk
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:
+Important:
+Enabled in order to make authorized requests.You can think of any API Key as another user in your Onspring instance and therefore it is subject to all the same permission considerations as any other user when it comes to its ability to access data in your instance. The API Key you use needs to have all the correct permissions within your instance to access the data requested. Things to think about in this context are role security, content security, and field security.
OnspringClientThe 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.comapiKey - the value obtained by following the steps in the API Key sectionIt 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
const { OnspringClient } = require('onspring-api-sdk');
const dotenv = require('dotenv');
dotenv.config();
const client = new OnspringClient(process.env.BASE_URL, process.env.API_KEY);
+
+ES Module
import dotenv from 'dotenv';
import { OnspringClient } from 'onspring-api-sdk';
dotenv.config();
const client = new OnspringClient(process.env.BASE_URL, process.env.API_KEY);
+
+Axios Instance ConfigurationBy default when you construct an instance of the OnspringClient a new Axios instance will also be created. Its baseURL property will always be set to the baseUrl parameter based to the OnspringClient's constructor and its headers will always contain the proper x-api-key header.
You can though pass a third optional argument to the OnspringClient constructor that specifies additional configuration options for the Axios instance used to make requests.
import dotenv from 'dotenv';
import { OnspringClient } from 'onspring-api-sdk';
dotenv.config();
const configs = {
timeout: 5000,
};
const client = new OnspringClient(
process.env.BASE_URL,
process.env.API_KEY,
configs
);
+
+ApiResponseEach 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 successfulThere is support for using either CommonJS or ES Modules depending upon your preference. This documentation will use the later in the usage examples.
+The package is written in typescript and all types are exported and available for you to use.
+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.
Note the following code snippets assume you've already instantiated an OnspringClient as shown in the OnspringClient section.
const res = await client.canConnect();
console.log(res); // true or false
+
+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.
+const res = await client.getApps();
const apps = res.data.items;
for (const app of apps) {
console.log(app);
}
+
+You can set your own page size and page number (max is 1,000) as well.
+import { PagingRequest } from 'onspring-api-sdk';
const res = await client.getApps(new PagingRequest(1, 1));
const apps = res.data.items;
for (const app of apps) {
console.log(app);
}
+
+Returns an Onspring app or survey according to provided id.
+const res = await client.getAppById(130);
const app = res.data;
console.log(app);
+
+Returns a collection of Onspring apps and/or surveys according to provided ids.
+const res = await client.getAppsByIds([130, 131]);
const apps = res.data.items;
for (const app of apps) {
console.log(app);
}
+
+Returns an Onspring field according to provided id.
+const res = await client.getFieldById(4793);
const field = res.data;
console.log(field);
+
+Returns a collection of Onspring fields according to provided ids.
+const res = await client.getFieldsByIds([4793, 4801]);
const fields = res.data.items;
for (const field of fields) {
console.log(field);
}
+
+Returns a paged collection of fields that can be paged through. By default the page size is 50 and page number is 1.
+const res = await client.getFieldsByAppId(132);
const fields = res.data.items;
for (const field of fields) {
console.log(field);
}
+
+You can set your own page size and page number (max is 1,000) as well.
+import { PagingRequest } from 'onspring-api-sdk';
const res = await client.getFieldsByAppId(132, new PagingRequest(1, 1));
const fields = res.data.items;
for (const field of fields) {
console.log(field);
}
+
+Returns the Onspring file's metadata.
+const res = await client.getFileInfoById(1, 4806, 909);
const fileInfo = res.data;
console.log(fileInfo);
+
+Returns the file itself.
+import fs from 'fs';
const res = await client.getFileById(1, 4806, 909);
const file = res.data;
console.log(file.contentLength);
console.log(file.contentType);
console.log(file.fileName);
file.stream.pipe(fs.createWriteStream(file.fileName));
+
+import fs from 'fs';
import { SaveFileRequest } from 'onspring-api-sdk';
const request = new SaveFileRequest(
1,
4806,
'notes',
new Date(),
'test-attachment.txt',
'text/plain',
fs.createReadStream('test-attachment.txt')
);
const res = await client.saveFile(request);
const fileId = res.data.id;
console.log(fileId);
+
+const res = await client.deleteFileById(1, 4806, 1505);
res.statusCode === 204
? console.log('File deleted')
: console.log('Error deleting file');
+
+To add a list value don't provide an id value.
+import { ListItemRequest } from 'onspring-api-sdk';
const request = new ListItemRequest(638, null, 'New Value', 1, '#000000');
const res = await client.addOrUpdateListItem(request);
const itemId = res.data.id;
console.log(itemId);
+
+To update a list value provide an id value.
+import { ListItemRequest } from 'onspring-api-sdk';
const request = new ListItemRequest(
638,
'35c79a46-04b8-4069-bbc1-161a175f962c',
'Updated Value',
1,
'#000000'
);
const res = await client.addOrUpdateListItem(request);
const itemId = res.data.id;
console.log(itemId);
+
+const res = await client.deleteListItemById(
638,
'35c79a46-04b8-4069-bbc1-161a175f962c'
);
res.statusCode === 204
? console.log('List item deleted')
: console.log('Error deleting list item');
+
+Returns a paged collection of records that can be paged through. By default the page size is 50 and page number is 1.
+import { GetRecordsByAppIdRequest } from 'onspring-api-sdk';
const request = new GetRecordsByAppIdRequest(130);
const res = await client.getRecordsByAppId(request);
const records = res.data.items;
for (const record of records) {
console.log(record);
}
+
+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.
+import {
DataFormat,
GetRecordsByAppIdRequest,
PagingRequest,
} from 'onspring-api-sdk';
const request = new GetRecordsByAppIdRequest(
130,
[4804],
DataFormat.Raw,
new PagingRequest(1, 1)
);
const res = await client.getRecordsByAppId(request);
const records = res.data.items;
for (const record of records) {
console.log(record);
}
+
+Returns an onspring record based on the provided app and record ids.
+import { GetRecordRequest } from 'onspring-api-sdk';
const request = new GetRecordRequest(130, 1);
const res = await client.getRecordById(request);
const record = res.data;
console.log(record);
+
+You can also specify what field values to return and in what format (Raw vs. Formatted) to return them.
+import { DataFormat, GetRecordRequest } from 'onspring-api-sdk';
const request = new GetRecordRequest(130, 1, [4804], DataFormat.Raw);
const res = await client.getRecordById(request);
const record = res.data;
console.log(record);
+
+Returns a collection of Onspring records based on the provided appId and recordIds.
+import { GetRecordsRequest } from 'onspring-api-sdk';
const request = new GetRecordsRequest(130, [1]);
const res = await client.getRecordsByIds(request);
const records = res.data.items;
for (const record of records) {
console.log(record);
}
+
+You can also specify what field values to return and in what format (Raw vs. Formatted) to return them.
+import { DataFormat, GetRecordsRequest } from 'onspring-api-sdk';
const request = new GetRecordsRequest(130, [1], [4804], DataFormat.Formatted);
const res = await client.getRecordsByIds(request);
const records = res.data.items;
for (const record of records) {
console.log(record);
}
+
+Returns a paged collection of records based on a criteria that can be paged through. By default the page size is 50 and page number is 1.
+import {
FilterOperators,
QueryFilter,
QueryRecordsRequest,
} from 'onspring-api-sdk';
const filter = new QueryFilter(4745, FilterOperators.GreaterThan, 0);
const request = new QueryRecordsRequest(130, filter);
const res = await client.queryRecords(request);
const records = res.data.items;
for (const record of records) {
console.log(record);
}
+
+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.
+import {
DataFormat,
FilterOperators,
PagingRequest,
QueryFilter,
QueryRecordsRequest,
} from 'onspring-api-sdk';
const filter = new QueryFilter(4745, FilterOperators.GreaterThan, 0);
const request = new QueryRecordsRequest(
130,
filter,
[4804],
DataFormat.Formatted,
new PagingRequest(1, 1)
);
const res = await client.queryRecords(request);
const records = res.data.items;
for (const record of records) {
console.log(record);
}
+
+For further details on constructing the filter parameter please refer to the documentation for the Onspring API.
You can add a record by not providing a record id value. If successful will return the id of the added record.
+import { Record, StringRecordValue } from 'onspring-api-sdk';
const record = new Record(130, null);
const fieldValue = new StringRecordValue(4804, 'Test');
record.addValue(fieldValue);
const res = await client.saveRecord(record);
const newRecordId = res.data.id;
console.log(newRecordId);
+
+You can update a record by providing its id. If successful will return the id of record updated.
+import { Record, StringRecordValue } from 'onspring-api-sdk';
const record = new Record(130, 607);
const fieldValue = new StringRecordValue(4804, 'Updated');
record.addValue(fieldValue);
const res = await client.saveRecord(record);
const updatedRecordId = res.data.id;
console.log(updatedRecordId);
+
+Delete an individual record based upon its id.
+const res = await client.deleteRecordById(130, 607);
res.statusCode === 204
? console.log('Record deleted')
: console.log('Error deleting record');
+
+Delete a batch of records based upon their ids.
+const res = await client.deleteRecordsByIds(130, [608, 609]);
res.statusCode === 204
? console.log('Records deleted')
: console.log('Error deleting records');
+
+Returns the report for the provided id.
+const res = await client.getReportById(408);
const report = res.data;
console.log(report);
+
+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.
+import { DataFormat, ReportDataType } from 'onspring-api-sdk';
const res = await client.getReportById(
409,
DataFormat.Formatted,
ReportDataType.ChartData
);
const report = res.data;
console.log(report);
+
+Returns a paged collection of reports that can be paged through. By default the page size is 50 and page number is 1.
+const res = await client.getReportsByAppId(130);
const reports = res.data.items;
for (const report of reports) {
console.log(report);
}
+
+You can set your own page size and page number (max is 1,000) as well.
+import { PagingRequest } from 'onspring-api-sdk';
const res = await client.getReportsByAppId(130, new PagingRequest(1, 1));
const reports = res.data.items;
for (const report of reports) {
console.log(report);
}
+
+Generated using TypeDoc
Generated using TypeDoc
ApiResponse - A generic response object for API requests.
+