https://github.com/mergentlabs/mergent-js
JavaScript / TypeScript library for the Mergent API.
https://github.com/mergentlabs/mergent-js
javascript js mergent node ts typescript
Last synced: about 1 year ago
JSON representation
JavaScript / TypeScript library for the Mergent API.
- Host: GitHub
- URL: https://github.com/mergentlabs/mergent-js
- Owner: mergentlabs
- Created: 2021-12-25T23:51:58.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T01:25:31.000Z (over 1 year ago)
- Last Synced: 2025-04-11T22:58:13.824Z (about 1 year ago)
- Topics: javascript, js, mergent, node, ts, typescript
- Language: TypeScript
- Homepage: https://mergent.co
- Size: 1.32 MB
- Stars: 20
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Mergent JavaScript Library
[](https://badge.fury.io/js/mergent)
[](https://github.com/mergentlabs/mergent-js/actions/workflows/ci.yml)
The Mergent JavaScript library provides convenient access to the Mergent API
from applications written in the JavaScript language.
## Installation
Install the package with:
```sh
npm install mergent --save
# or
yarn add mergent
```
## Usage
The library needs to be configured with your project's API key. Set
`Mergent.api_key` to its value:
```js
const Mergent = require("mergent");
// set the Mergent API key
const mergent = new Mergent("...");
// create a Task that will make an HTTP request in 5 minutes
mergent.tasks
.create({
request: { url: "...", body: "Hello, world!" },
delay: { minutes: 5 },
})
.then((task) => console.log(task))
.catch((error) => console.error(error));
// create a recurring Schedule that will make an HTTP request every minute
mergent.schedules
.create({
request: { url: "...", body: "Hello, world!" },
cron: "* * * * *",
})
.then((task) => console.log(task))
.catch((error) => console.error(error));
```
### Usage with TypeScript
```ts
import Mergent from "mergent";
// set the Mergent API key
const mergent = new Mergent("...");
// create a Task that will make an HTTP request in 5 minutes
mergent.tasks
.create({
request: { url: "...", body: "Hello, world!" },
delay: { minutes: 5 },
})
.then((task) => console.log(task))
.catch((error) => console.error(error));
// create a recurring Schedule that will make an HTTP request every minute
mergent.schedules
.create({
request: { url: "...", body: "Hello, world!" },
cron: "* * * * *",
})
.then((task) => console.log(task))
.catch((error) => console.error(error));
```
See the [Mergent JavaScript docs](https://docs.mergent.co/libraries/javascript)
for more details.
## Development
After checking out the repo, run `npm install` to install dependencies. Then,
run `npm test` to run the tests.
## Contributing
Bug reports and pull requests are welcome on GitHub at
https://github.com/mergentlabs/mergent-js.
## Distributing
1. Update the version with `npm version ` (this makes a new commit)
1. Amend that commit with updates to the CHANGELOG
1. Push with `git push --tags`
1. Package with `npm run package`
1. Publish with `npm publish`
## License
The library is available as open source under the terms of the
[MIT License](https://opensource.org/licenses/MIT).