---
title: "Javascript Scheduler Load Events from Remote API Example | Mobiscroll"
component: "Scheduler"
framework: "JavaScript"
library_version: "6.1.5"
url: "https://demo.mobiscroll.com/javascript/scheduler/load-events-from-remote-api"
---

# Load Events from Remote API - JavaScript Scheduler demo

Populate a Javascript Scheduler from a remote API — fetch from your backend or third-party source and pass data in the format the scheduler expects. Plain JavaScript API.

- [Live demo](https://demo.mobiscroll.com/javascript/scheduler/load-events-from-remote-api)
- [View code on GitHub](https://github.com/acidb/mobiscroll-demos-javascript/tree/main/src/demos/eventcalendar/scheduler/load-events-from-remote-api)
- This demo in other frameworks: [jQuery](https://demo.mobiscroll.com/jquery/scheduler/load-events-from-remote-api.md), [Angular](https://demo.mobiscroll.com/angular/scheduler/load-events-from-remote-api.md), [React](https://demo.mobiscroll.com/react/scheduler/load-events-from-remote-api.md), [Vue](https://demo.mobiscroll.com/vue/scheduler/load-events-from-remote-api.md)

## Description

The scheduler can be populated by passing an array to the [`data`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-data) option, that you can construct either inline or by getting it from a remote API. The important thing to remember is that events need to be [in a format that the scheduler understands](https://demo.mobiscroll.com/javascript/scheduler/event-data-structure).

**Interested in load on demand?** [Dynamically load events on month change →](https://demo.mobiscroll.com/javascript/scheduler/load-events-on-demand)

## What this demo shows

- A mobile daily scheduler view with a fixed week strip at the top, a fixed all-day row below it, and a scrollable time grid for the selected day.
- **Header navigation** The month and year label in the top left opens date navigation, while the blue previous and next arrows and the Today button on the right make it easy to move between dates and jump back to the current day.
- **Week view** The fixed week strip below the header shows the surrounding dates for quick day switching. Dates highlight on hover, and the selected day is marked with a blue circle.
- **All-day events** All-day events are displayed in a dedicated row that stays fixed above the time grid.
- **Time grid** The scheduler below the all-day row scrolls vertically through the hours of the selected day.
- **Hover feedback** Hovering the time grid shows a time indicator that follows the pointer in 15-minute increments.
- **Event rendering** Events appear as colored cards with a colored stripe on the left, the event title in bold, and the exact start and end time displayed above the title.
- **Event overlapping** If events overlap, the scheduler places them side by side without hiding any of them or causing other conflicts.
- **Event interactions** Hovering an event highlights it and shows resize and drag handles, indicating that events can be resized or repositioned.
- **Event creation** Double-clicking the time grid or clicking and dragging on it creates a new event.
- **Event selection** Clicking an event selects and highlights it.
- **Current time** A blue line across the scheduler indicates the current time.

## Best for

- **Remote event loading examples** Showing how to fetch events from an API and pass them to the scheduler view.

## API used in this demo

- [`theme`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-theme) - option
- [`themeVariant`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-themeVariant) - option
- [`clickToCreate`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-clickToCreate) - option
- [`dragToCreate`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-dragToCreate) - option
- [`dragToMove`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-dragToMove) - option
- [`dragToResize`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-dragToResize) - option
- [`eventDelete`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-eventDelete) - option
- [`view`](https://mobiscroll.com/docs/javascript/eventcalendar/api#opt-view) - option
- [`setEvents`](https://mobiscroll.com/docs/javascript/eventcalendar/api#method-setEvents) - method

## Code

### JS

```js
var inst = mobiscroll.eventcalendar('#demo-remote-api', {
  theme: 'ios',
  themeVariant: 'light',
  clickToCreate: true,
  dragToCreate: true,
  dragToMove: true,
  dragToResize: true,
  eventDelete: true,
  view: {
    calendar: { type: 'week' },
    scheduler: { type: 'day' },
  },
});

mobiscroll.getJson(
  'https://trial.mobiscroll.com/events/?vers=5',
  function (events) {
    inst.setEvents(events);
  },
  'jsonp',
);
```

### HTML

```html
<div id="demo-remote-api"></div>
```

## Implementation notes

- Use a combined view: `view: { calendar: { type: 'week' }, scheduler: { type: 'day' } }` - a week calendar strip above and a day scheduler below.
- Load events from `https://trial.mobiscroll.com/events/?vers=5` via JSONP using `getJson(url, callback, 'jsonp')`. For the imperative API, call `inst.setEvents(events)` in the callback.

## Run it in your project

1. If not signed up yet, or don't own a license, you can [start a free trial](https://mobiscroll.com/starttrial).

2. Clone the repository:

   ```
   git clone https://github.com/acidb/mobiscroll-demos-javascript.git
   ```

3. If not installed yet, install the Mobiscroll CLI from NPM:

   ```
   npm install -g @mobiscroll/cli
   ```

4. Config Mobiscroll - open a terminal window in the root directory and run:

   ```
   mobiscroll config javascript
   ```

5. Install dependencies - open a terminal window in the root directory and run:

   ```
   npm install
   ```

6. Run the project:

   ```
   npm run dev
   ```

On a trial, add `--trial` to the config command: `mobiscroll config javascript --trial`.

Running a demo locally requires a Mobiscroll trial or a license; setup is per framework at https://mobiscroll.com/docs/javascript/getting-started/installation

## Related demos

- Previous: [Inline Data](https://demo.mobiscroll.com/javascript/scheduler/load-inline-data.md) - Pass a static event array to the Javascript Scheduler to see how event data is structured — before connecting a live or on-demand data source.
- Next: [Load Events on Demand](https://demo.mobiscroll.com/javascript/scheduler/load-events-on-demand.md) - Fetch Javascript scheduler events as users navigate between dates — use a lifecycle callback to load only the visible date range from a remote or local source.
