0

I use a Activecollab V5 ( self-hosted ) and I would like to pull data via APIs . I have read API documentation here

API Documentation

The issue is that I dont know how to use it . I need to know how to generate a token and how to make requests to API endpoints in the documentation above . Can someone please help with this ? . Thanks .

1 Answers1

0

It entirely depends on the language you're planning on using to access the API.

We use PHP and to do the heavy lifting we use the Feather SDK provided by AC themselves. The readme provides a good example of how to get started.

I believe there are other SDKs available for different languages.

Once you've included it, you can then run the queries as described in the documentation. There are some gotchas though, as the documentation doesn't reveal everything and only gives you specific use cases.

For example, the API returns ~100 results per page, but with no indication that there is a second page, so if the results equal 100, chances are there are more to be retrieved.

I've made this PHP function within my app to help me get all the records. It keeps requesting the next page until there is nothing more to process.

The $url param passed in is something like projects or projects/archive.

/**
 * Get pages of data with passed url
 * @param [string] $url The api endpoint
 * @return [array] All your data
 */
function getPagedData($url) {
    // Get all the projects in active collab
    $page = 1;
    $paged_records = array();
    $paged_records_results = $this->activeCollabClient->get($url . '?page=' . $page)->getJson();
    $paged_records = array_merge($paged_records, $paged_records_results);

    // Loop through pages
    while ($paged_records_results = $this->activeCollabClient->get($url . '?page=' . ++$page)->getJson()) {
        $paged_records = array_merge($paged_records, $paged_records_results);
    }
    return $paged_records;
}

Hope that helps!

mikestreety
  • 833
  • 6
  • 28