https://github.com/merge-api/merge-sdk-typescript
The Node SDK for accessing various Merge Unified APIs
https://github.com/merge-api/merge-sdk-typescript
Last synced: 4 months ago
JSON representation
The Node SDK for accessing various Merge Unified APIs
- Host: GitHub
- URL: https://github.com/merge-api/merge-sdk-typescript
- Owner: merge-api
- License: other
- Created: 2022-04-12T18:31:30.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-09T20:16:28.000Z (almost 3 years ago)
- Last Synced: 2025-08-08T19:33:51.131Z (10 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.37 MB
- Stars: 7
- Watchers: 9
- Forks: 5
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Deprecation Notice
Merge has released a new version of our [Typescript SDK](https://github.com/merge-api/merge-node-client/). As part of that release, we are providing a deprecation notice of our legacy SDKs.
To help give you time to plan your migration to our latest SDK:
- August 2023: SDK deprecation notice on our legacy Typescript SDKs.
- Until February 2024: we’ll support updates as needed and address bugs in priority order
- After February 2024: we’ll no longer make updates or bug fixes to the deprecated SDKs
For information about the deprecation notice see our [help center](https://help.merge.dev/en/collections/4258952-sdks) and for information about migrating to the Typescript SDK, see the [Typescript Migration Guide](https://help.merge.dev/en/articles/8229417-advanced-node-sdk-migration-guide).
## @mergeapi/merge-sdk-typescript@3.0.10
This is the Merge API, Inc. SDK client for Typescript. It utilizes [Fetch API](https://fetch.spec.whatwg.org/) to
make requests to Merge on behalf of customers. We recommend only using this module in NodeJS server environments.
Language level
- ES5 - you must have a Promises/A+ library installed
- ES6
Module system
- CommonJS
- ES6 module system
It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))
## Documentation
The documentation for various Merge category API's can be found here:
- [Accounting](https://www.merge.dev/docs/accounting/overview/)
- [ATS](https://www.merge.dev/docs/ats/overview/) (Applicant Tracking Systems)
- [CRM](https://www.merge.dev/docs/crm/overview/) (Customer Relationship Management)
- [HRIS](https://www.merge.dev/docs/hris/overview/) (Human Resource Information Systems)
- [Ticketing](https://www.merge.dev/docs/ticketing/overview/)
### Basic Usage
Common to all categories is the Merge SDK `Configuration` object, which defines the authentication properties of
your requests. The `apiKey` property is the API Key of your Merge account, which can be administered in the
[Merge dashboard](https://app.merge.dev/configuration/keys). The `accessToken` property will be the
`X-Account-Token` header which identifies which of your customers' data you are requesting. See the following
examples for calling various category API's:
#### node-fetch override on Node version < 17.5
This SDK relies on the Fetch API, which is baked into Node starting at version 17.5. For those customers on older
versions of Node, we allow you to explicitly set the fetchApi property like so:
```
import fetch from 'node-fetch'
...
let test_conf_crm = new Configuration({
apiKey: "REDACTED",
accessToken: "REDACTED",
fetchApi: fetch
});
```
You can find the node-fetch package here: https://www.npmjs.com/package/node-fetch . We have tested that
node-fetch @ 2.x.x can be passed in directly on Node version 16.0.0, however later versions of node-fetch or later
versions of Node may require additional type adjustments to make it work.
#### Accounting
```
const confAccounting = new Configuration({
apiKey: "REDACTED-YourAPIKeyWithMerge",
accessToken: "REDACTED-YourCustomer1Key"
});
const accountsApi = new merge_sdk.Accounting.AccountsApi(confAccounting);
// lists the accounting accounts for customer 1
let response = await accountsApi.accountsList({}).catch((reason) => {
console.log(reason);
});
console.log(response);
```
#### ATS
```
const confAts = new Configuration({
apiKey: "REDACTED-YourAPIKeyWithMerge",
accessToken: "REDACTED-YourCustomer1Key"
});
const candidatesApi = new merge_sdk.ATS.CandidatesApi(confAts);
// lists ats candidates for customer 1
let response = await candidatesApi.candidatesList({}).catch((reason) => {
console.log(reason);
});
console.log(response);
```
#### CRM
```
const confCrm = new Configuration({
apiKey: "REDACTED-YourAPIKeyWithMerge",
accessToken: "REDACTED-YourCustomer1Key"
});
const contactsApi = new merge_sdk.CRM.ContactsApi(confCrm);
// lists crm contacts for customer 1
let response = await contactsApi.contactsList({});
console.log(response);
```
#### HRIS
```
const confHris = new Configuration({
apiKey: "REDACTED-YourAPIKeyWithMerge",
accessToken: "REDACTED-YourCustomer1Key"
});
const employeesApi = new merge_sdk.HRIS.EmployeesApi(confHris);
// list all employess reporting to managerId: x for customer 1
let response = await employeesApi.employeesList({
managerId: "REDACTED"
});
console.log(response);
```
#### Ticketing
```
const confTicketing = new Configuration({
apiKey: "REDACTED-YourAPIKeyWithMerge",
accessToken: "REDACTED-YourCustomer1Key"
});
const ticketsApi = new merge_sdk.Ticketing.TicketsApi(confTicketing);
// list all ticketing tickets for customer 1
let response = await ticketsApi.ticketsList({});
console.log(response);
```
### Enums
Merge's API tries to unify enum values across integrations for a given category. However, there will be
sporadic cases where integration enum values are too unique to be mapped. In these cases, the value will
come back as-is. In order to support this behavior, starting in v3.0.0 of merge-sdk-typescript, all enum
values will be wrapped in an interface like:
```
{
value: EnumValue,
rawValue: string
}
```
Where the `rawValue` property will be the string from the Merge API, which may be the enum value as-is
from the integration source.
### Building
To build and compile the typescript sources to javascript use:
```
npm install
npm run build
```
### Tests
There is a single rough test for the SDK which calls one API from each category. To run it, you must set
configuration variables with the relevant API key and access token for each category. Additionally, the HRIS
section of the test checks an optional filtering query parameter.
### Consuming
navigate to the folder of your consuming project and run one of the following commands.
_published:_
```
npm install @mergeapi/merge-sdk-typescript@3.0.9 --save
```
_unPublished (not recommended):_
```
npm install PATH_TO_GENERATED_PACKAGE --save
```