Perfect Gym api

Pagination

PerfectGym API endpoint that returns list of resources usualy use pagination.

Overview

For pagination API uses two distinct techniques:

Page numbering is 1-based, page size is 100.

Each API endpoint that returns paginated result is marked as paginated in endpoint description. Selected pagination method is described alongside endpoint parameters description.

Pagination using timestamp query string parameter

Requests with timestamp query string parameter return list of resources added or changed after point in time represented by timestamp value. Result is ordered by timestamp ascending and is paged with page size of 100.

To get next page, use last element's timestamp in subsequent request.

To get all elements iterate with timestamp parameter untill you get result with less then 100 elements.

Example

In this example we fetch list of available in club with id = 2 classes. (Several element properties in JSON response were ommited for clarity)

First page, timestamp parameter is equal 0. It means that we fetch all elements, regardless of time they were last modified.

curl -i 
     -X GET 
     -H "Authorization: Bearer  $ACCESS_TOKEN"  
     http://yoursubdomain.perfectgym.com/Api/Classes/Classes
          ?clubId=2
          &timestamp=0      
Status: 200 OK
{
  "elements": [
    {
      "Elements omitted for clarity": "..."
    },
    {
      "id": 1677,
      "timestamp": 254718,
      "isDeleted": false,
      "startDate": "2015-12-03T06:15:00",
      "endDate": "2015-12-03T07:15:00",
      "attendeesCount": 7,
      "attendeesLimit": 20,
      "clubZone": "Fitness"
    }
  ]
}

Second page, timestamp parameter of value 254718 is provided. It means that we fetch all elements with timestamp greater then 254718 (value of last element's timestamp` in previous request).

curl -i 
     -X GET 
     -H "Authorization: Bearer  $ACCESS_TOKEN"  
     http://yoursubdomain.perfectgym.com/Api/Classes/Classes
          ?clubId=2
          &timestamp=254718         
Status: 200 OK
{
  "elements": [
    {
      "id": 2345,
      "timestamp": 366718,
      "isDeleted": false,
      "startDate": "2015-12-28T08:00:00",
      "endDate": "2015-12-28T09:00:00",
      "attendeesCount": 0,
      "attendeesLimit": 20,
      "clubZone": "Fitness"
    }
  ]
}

Pagination using page query string parameter

We use page query string parameter to choose a page. page parameter is always optional. The default page is the first one, so if you ommit page parameter, API will return first page.

To get all elements iterate with page parameter untill you get result with less then 100 elements.

Example

In this example we fetch list of available in club with id = 2 classes, that starts in december 2015.

First page (page parameter is ommited, so it defaults to 1)

curl -i 
     -X GET 
     -H "Authorization: Bearer  $ACCESS_TOKEN"  
     http://yoursubdomain.perfectgym.com/Api/Classes/Classes
          ?clubId=2
          &startDate=2015-12-01T00:00:00
          &endDate=2015-12-31T23:59:59

Second page (page parameter of value 2 is provided)

curl -i 
     -X GET 
     -H "Authorization: Bearer  $ACCESS_TOKEN"  
     http://yoursubdomain.perfectgym.com/Api/Classes/Classes/
          ?clubId=2
          &startDate=2015-12-01T00:00:00
          &endDate=2015-12-31T23:59:59
          &page=2
Perfect Gym api