fetchActivities - Methods - Author API

Author API Methods

fetchActivities()

Performs an Activity search using the provided search parameters.

You would want to use this method to build a custom Activity search feature in your application, for example.

Note This method does not return full Activity JSON. It returns a subset of Activity data used to render the Activity list view.

Note This method can be called from any view.

Examples

var searchParameters = {
    "limit": 2,
    "reference": "4823",
    "sort": "desc",
    "sort_field": "created",
    "status": ["published"],
    "tags": {
        "all": [
            {
                "type": "Subject",
                "name": "English"
            }
        ]
    }
};
var activitiesPromise = authorApp.fetchActivities(searchParameters);

activitiesPromise.then(response => {
    console.log(response.activities);

    // Fetch the next page of results
    if (response.next) {
        searchParameters.next = response.next;
        return authorApp.fetchActivities(searchParameters);
    }
}).catch(() => {
    console.log('The search failed.');
});

/*
{
    "activities": [
        {
            "reference": "1ba18b07-4823-4e78-aea7-4729111a24d3",
            "title": "My Activity title",
            "description": "",
            "status": "published",
            "type": "regular",
            "items_count": 2,
            "max_time": null,
            "dt_created": "2026-11-18 15:03:36",
            "dt_updated": "2026-11-18 17:24:34",
            "created_by": {
                "id": "author@example.com",
                "first_name": "Jane",
                "last_name": "Author",
                "email": null
            },
            "last_updated_by": {
                "id": "author@example.com",
                "first_name": "Jane",
                "last_name": "Author",
                "email": null
            },
            "tags": [
                {
                    "type": "Subject",
                    "name": "English"
                }
            ],
            "tagsCount": 1
        },
        { ... }
    ],
    "next": [1794962851000, 2241972]
}
*/

Arguments

  • searchParameters object

    Object containing search parameters to filter the search results by.

    Use any combination of the available properties to filter the search results. Unrecognized properties are ignored.

    The following properties are supported.

    • description string

      Filters Activities by whether their description contains the provided text.

    • limit number

      Specifies the maximum number of Activities to return.

      The maximum value is 100. Values greater than 100, or less than 1, return up to 100 Activities.

      Default: 100

    • next array

      Specifies the pagination cursor used to fetch the next page of results.

      Pass the next value from the previous response back unchanged, with all other search parameters unchanged, to fetch the following page.

      Omit this property to retrieve the first page, and whenever any other search parameter changes.

    • reference string

      Filters Activities by reference. Supports partial matching.

    • sort string

      Specifies the sort direction.

      Default: "desc"

      Possible values

      • "asc"
      • "desc"
    • sort_field string

      Specifies the field used to sort the results.

      Important Any other value causes the promise to be rejected.

      Default: "updated"

      Possible values

      • "updated"
      • "created"
      • "title"
      • "reference"
    • status array[string][string]

      Filters results by Activity status.

      Important Passing a value that is not an array causes the promise to be rejected.

      Default: ["published", "unpublished"]

      Possible values

      • "published"
      • "unpublished"
      • "archived"
    • tags object

      Filters results by Tags.

      The following properties are supported.

      • all array[object]

        Filters Activities that have all of the specified Tags.

      • either array[object]

        Filters Activities that have at least one of the specified Tags.

      • none array[object]

        Filters Activities that have none of the specified Tags.

    • title string

      Filters Activities by title. Supports partial matching.

Return value

Type Promise

The promise resolves with an object that has the following properties:

  • activities - an array of Activity list rows, up to limit (maximum 100). Each object contains data for one row of the Activity list, including the Activity reference, status, and other metadata such as time created, time updated and author.
  • next - a pagination cursor. Pass it back in searchParameters to fetch the next page. It is present only when the page is full, that is, when it contains limit rows. If it is missing, there are no more results. If the total number of results is an exact multiple of limit, the last request returns an empty activities array.

The promise rejects with false if the request fails.

Related articles

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.