icpay-cron
v1.0.2
Published
icCron SDK — Autonomous On-Chain Scheduled Triggers and Webhook Dispatcher on the Internet Computer
Maintainers
Readme
icpay-cron (npm / TypeScript SDK)
Official Node.js and TypeScript SDK for icCron, the autonomous on-chain cron and webhook dispatcher running on the Internet Computer (w2fxo-5qaaa-aaaan-q6zxq-cai).
Installation
npm install icpay-cronQuick Start
import { IcCronClient } from "icpay-cron"
const client = new IcCronClient({
apiKey: process.env.ICCRON_API_KEY,
})Methods
createJob(options)
Creates a new scheduled HTTP webhook or inter-canister job inside the API key's project.
const job = await client.createJob({
projectId: 1,
label: "Hourly Sync",
cronExpression: "0 * * * *",
target: {
type: "HttpWebhook",
url: "https://example.com/api/cron",
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ event: "sync" }),
},
})listJobs(projectId?)
Returns all jobs for the API key's project.
const jobs = await client.listJobs()trigger(options)
Immediately executes a job on-chain and logs the result.
const res = await client.trigger({
projectId: 1,
jobId: 1,
})pauseJob(jobId)
Pauses an active job and removes its next scheduled timer.
await client.pauseJob(1)resumeJob(jobId)
Resumes a paused job and schedules its next run.
await client.resumeJob(1)deleteJob(jobId)
Deletes a job and its stored execution logs.
await client.deleteJob(1)getJobLogs(jobId, limit?)
Returns recent execution logs for a specific job.
const logs = await client.getJobLogs(1)getProjectLogs()
Returns up to 100 recent execution logs across all jobs in the API key's project, sorted newest first.
const projectLogs = await client.getProjectLogs()