Loopwise Docs
Admin APIQueries

Membership Plans Query

Query operations for membership plans in the Loopwise Admin API

Note: The Loopwise Admin API is currently under development and not yet available for public use. This documentation is provided for preview purposes only.

Overview

The Membership Plans API allows you to retrieve information about subscription options available to students in your school. Each plan has specific features, pricing, and duration settings.

Available Queries

membershipPlans

Returns a paginated list of membership plans for the authenticated school.

Parameters:

ParameterTypeDescription
filterAdminMembershipPlanFilterFilter criteria (see Filtering)
pageIntPage number for pagination
perPageIntNumber of items per page (default: 20, max: 50)
limitIntAlternative to perPage

Returns:

  • AdminMembershipPlanPage object with:
    • nodes: Array of AdminMembershipPlan objects
    • currentPage: Current page number
    • hasNextPage: Whether there are more pages
    • hasPreviousPage: Whether there are previous pages
    • nodesCount: Total number of items in the current page
    • totalPages: Total number of pages

Example:

query {
  membershipPlans(
    filter: {
      active: true
    },
    page: 1,
    perPage: 10
  ) {
    nodes {
      id
      name
      description
      planType
      isLifetime
      price
      currency
      interval
      intervalCount
      active
      visible
      createdAt
      updatedAt
      totalRevenue
      subscriptions (
        filter: {
          planId: { eq: "abc123-983dsf8" }
        }
      ) {
        nodes {
          id
          planId
          state
          createdAt
        }
      }
    }
    currentPage
    hasNextPage
    hasPreviousPage
    nodesCount
    totalPages
  }
}

Membership Plan Object

The AdminMembershipPlan object contains the following fields based on the schema:

FieldTypeDescription
idString!Unique identifier
nameString!Plan name
descriptionStringPlan description
planTypeString!Plan type. Possible values: recurring, fixed_date, specific_length, lifetime
isLifetimeBoolean!Indicates whether this is a lifetime (permanent access) plan
priceFloat!Price of the plan
currencyString!Currency code (e.g., USD, EUR) in ISO 4217 format
intervalString!Billing interval (month, year, day)
intervalCountInt!Number of intervals (e.g., 1, 3, 6)
activeBoolean!Whether the plan is active
visibleBoolean!Whether the plan is visible to students
createdAtInt!When the plan was created
updatedAtInt!When the plan was last updated
soldItemsCountIntNumber of sold subscriptions
totalRevenueFloatTotal revenue generated by this plan
subscriptionsAdminSubscriptionPagePaginated list of subscriptions for this plan

Subscriptions Fields

The AdminMembershipPlan object includes subscription information through the subscriptions field. This returns a paginated list of subscriptions associated with the plan.

FieldTypeDescription
idString!Unique identifier for the subscription
stateString!Current state of the subscription
startAtIntWhen the subscription starts
endAtIntWhen the subscription ends
currentPeriodStartIntStart of current billing period
currentPeriodEndIntEnd of current billing period
isCancelingBoolean!Whether the subscription is scheduled for cancellation
isCancellableBoolean!Whether the subscription can be cancelled

User Information in Subscriptions

Each subscription includes user information through the user field:

FieldTypeDescription
idString!User's unique identifier
nameStringUser's full name
emailStringUser's email address

Subscriptions Filter Parameters

ParameterTypeDescription
idStringOperatorFilter by subscription ID
planIdStringOperatorFilter by subscription plan ID
stateStringOperatorFilter by subscription state

Example with filtered subscriptions:

query {
  membershipPlans(page: 1, perPage: 10) {
    nodes {
      id
      name
      subscriptions (
        filter: {
          state: {
            eq: "active"
          }
        }
      ) {
        nodes {
          id
          state
          startAt
          endAt
          currentPeriodStart
          currentPeriodEnd
          isCanceling
          isCancellable
          user {
            id
            name
            email
          }
        }
        currentPage
        nodesCount
      }
    }
  }
}

Detailed Query Structure

Below is a comprehensive view of fields available in the membershipPlans query based on the schema:

query {
  membershipPlans(
    filter: {
      id: { eq: "plan-123" },
      active: true,
      visible: true
    },
    page: 1,
    perPage: 20
  ) {
    nodes {
      id                          # Unique identifier (String!)
      name                        # Plan name (String!)
      description                 # Plan description (String)

      # Plan type
      planType                    # Plan type: recurring, fixed_date, specific_length, lifetime (String!)
      isLifetime                  # Whether this is a lifetime plan (Boolean!)

      # Plan pricing details
      price                       # Price amount (Float!)
      currency                    # Currency code (String!)

      # Subscription details
      interval                    # Billing interval (String!)
      intervalCount               # Number of intervals (Int!)

      # Plan status
      active                      # Whether the plan is active (Boolean!)
      visible                     # Whether the plan is visible (Boolean!)

      # Timestamps
      createdAt                   # When the plan was created (Int!)
      updatedAt                   # When the plan was last updated (Int!)

      # Statistics
      soldItemsCount              # Number of sold subscriptions (Int)
      totalRevenue                # Total revenue generated (Float)

      # Related subscriptions
      subscriptions (
        filter: {
          planId: { eq: "abc123-983dsf8" }
        }
      ) {
        # Subscriptions for this plan (AdminSubscriptionPage)
        nodes {
          id
          state
          startAt
          endAt
          currentPeriodStart
          currentPeriodEnd
          isCanceling
          isCancellable
          user {
            id
            name
            email
          }
        }
        currentPage
        hasNextPage
        nodesCount
      }
    }

    # Pagination information
    currentPage                   # Current page number (Int!)
    hasNextPage                   # Whether there are more pages (Boolean!)
    hasPreviousPage               # Whether there are previous pages (Boolean!)
    nodesCount                    # Number of items in current page (Int!)
    totalPages                    # Total number of pages (Int!)
  }
}

Filtering

The membershipPlans query accepts a filter parameter of type AdminMembershipPlanFilter. This allows you to narrow down results based on various criteria.

Available Filters

Filter FieldTypeDescription
idStringOperatorFilter by plan ID
activeBooleanFilter by active status
visibleBooleanFilter by visibility
planTypeStringOperatorFilter by plan type. Possible values: recurring, fixed_date, specific_length, lifetime

StringOperator

The StringOperator used in filters has these operations:

OperationDescription
eqEqual to
neqNot equal to
inIn a list of values
ninNot in a list of values
likeMatch text values against a pattern using wildcards (case-sensitive)

Filter Examples

Find active membership plans:

query {
  membershipPlans(
    filter: {
      active: true
    }
  ) {
    nodes {
      id
      name
      price
      currency
    }
    nodesCount
  }
}

Find visible membership plans:

query {
  membershipPlans(
    filter: {
      visible: true
    }
  ) {
    nodes {
      id
      name
      price
      currency
    }
    nodesCount
  }
}

Find membership plans by ID:

query {
  membershipPlans(
    filter: {
      id: { eq: "plan-123" }
    }
  ) {
    nodes {
      id
      name
      price
      currency
    }
    nodesCount
  }
}

Find lifetime membership plans:

query {
  membershipPlans(
    filter: {
      planType: { eq: "lifetime" }
    }
  ) {
    nodes {
      id
      name
      planType
      isLifetime
      price
      currency
    }
    nodesCount
  }
}

Find recurring or lifetime plans:

query {
  membershipPlans(
    filter: {
      planType: { in: ["recurring", "lifetime"] }
    }
  ) {
    nodes {
      id
      name
      planType
    }
    nodesCount
  }
}

Find all non-recurring plans:

query {
  membershipPlans(
    filter: {
      planType: { neq: "recurring" }
    }
  ) {
    nodes {
      id
      name
      planType
    }
    nodesCount
  }
}

On this page