Forem Creators and Builders

Ben Greenberg
Ben Greenberg

Posted on

Add date field to GET followers API endpoint

Problem

As a developer building apps and services with the API, I would like to be able to programmatically know who my new followers are, and when they followed my username and/or organization.

Similarly, as an API consumer, I would like to limit the number of API requests I need to make to the paginated resource by being able to filter based on a follow date query parameter, along with an order parameter of ascending or descending order.

Solution

The controller action responsible for this endpoint currently allows users to specify the page to retrieve and the number of items in the collection to return per page.

The action defaults to descending order for the collection, this can be changed to a query parameter.

Either the current created_at column in the Follow model can be used as the new date field in the API endpoint, if this is indeed the created date for the following relationship, or a new date field can be introduced that holds the value of when the follower began following the account.

Discussion (0)