Skip to content

Use cases

Poll an API for changes on an interval

When a service has no webhook, polling is how you keep up: hit its endpoint on a tight interval and process whatever changed. Cronhost runs the poll for you as often as every minute on paid plans and keeps a record of each check.

The problem

You need to check an external API regularly for new data, but you do not want to babysit a long-running worker or a cron box just to make a request every few minutes.

How to set it up

  1. 1

    Create a schedule that hits your sync endpoint

    Point the schedule at an endpoint in your app that pulls from the external API and processes the changes. Set the interval as tight as your plan allows.

    const poll = await cronhost.createSchedule({ name: "Poll orders", cronExpression: "*/5 * * * *", // every 5 minutes timezone: "UTC", endpoint: "https://api.example.com/orders/sync", httpMethod: "GET", maxRetries: 2, });
  2. 2

    Keep the work on your side idempotent

    Because polling runs often, make the endpoint safe to call repeatedly: track what you have already processed so a duplicate run does not double-handle the same data. Cronhost guarantees the run fires on time; your endpoint decides what is new.

  3. 3

    Mind the interval and your plan limits

    Tighter intervals mean more executions. Paid plans support one-minute syntax, while Free starts at thirty minutes. Check your monthly execution count on the dashboard and choose the loosest interval that meets your needs.

Example cadence: Run a cron job every 5 minutes

Poll any API without running a worker

Set an interval, point at your sync endpoint, and let Cronhost do the checking.

Frequently asked questions