# Pull member data from EGYM This guide explains how to pull member account data from EGYM to your system. Use this approach when you are a non-MMS partner who needs to retrieve membership data that was sent to EGYM by MMS partners. ## Overview The [list members endpoint](/mms-api-v2/apis/mms-v2/member-account/listaccounts) allows you to fetch member accounts from EGYM. This is useful when: - You need to access member information managed by gym management systems - You need to perform an initial bulk import of member data - You want to keep your system synchronized with EGYM on a regular schedule ## How pagination works The [list member account endpoint](/mms-api-v2/apis/mms-v2/member-account/listaccounts) uses offset-based pagination. To retrieve all members, you'll need to make multiple requests with increasing offset values. ### Pagination parameters - `limit` - Number of records per page (use the default or specify your own) - `offset` - Starting position for the current page (0 for first page) - `hasNext` - Response field indicating if more pages are available ### Pagination example For a gym with 29 member accounts and a limit of 10 per page: **First page:** ``` GET /api/v2/accounts?offset=0&limit=10 ``` Response: 10 members, `"hasNext": true` **Second page:** ``` GET /api/v2/accounts?offset=10&limit=10 ``` Response: 10 members, `"hasNext": true` **Third page (last):** ``` GET /api/v2/accounts?offset=20&limit=10 ``` Response: 9 members, `"hasNext": false` Continue fetching pages until `hasNext` is `false`. ## Initial sync Perform an initial sync when you first integrate with EGYM or need to rebuild your local member database. ### Steps for initial sync 1. Call the [list members endpoint](/mms-api-v2/apis/mms-v2/member-account/listaccounts) without time filters 2. Process the first page of member accounts 3. Continue making requests with increasing `offset` values until `hasNext` is `false` 4. Store the timestamp when the sync completed for future incremental syncs ### Example ``` # First request GET /api/v2/accounts?offset=0&limit=100 # Continue until hasNext is false GET /api/v2/accounts?offset=100&limit=100 GET /api/v2/accounts?offset=200&limit=100 ... ``` ## Incremental sync For ongoing synchronization, use time-based filters to fetch only members that have been created or updated since your last sync. ### Steps for incremental sync Set up a scheduled job (e.g., every 10 minutes) to pull updates: 1. **First run (optional):** Perform initial sync and store the timestamp 2. **Schedule regular calls:** Set up your job to run at your desired interval (e.g., every 10 minutes) 3. **Use time windows:** Include time filters in each call: - `fromTimestamp` - Timestamp of your last successful sync - `toTimestamp` - Current timestamp (store this for the next sync) 4. **Fetch all pages:** Make subsequent paginated requests using the same time window until `hasNext` is `false` ### Example: 10-minute sync schedule ``` # First sync at 10:00 GET /api/v2/accounts?fromTimestamp=2024-01-01T09:50:00Z&toTimestamp=2024-01-01T10:00:00Z&offset=0 # Next sync at 10:10 GET /api/v2/accounts?fromTimestamp=2024-01-01T10:00:00Z&toTimestamp=2024-01-01T10:10:00Z&offset=0 # Continue... ``` **Important:** Always use the same time window parameters (`fromTimestamp` and `toTimestamp`) across all paginated requests in a single sync run. Don't update the timestamps while fetching pages. ## Best practices 1. **Choose appropriate sync intervals** - Balance between data freshness and API load (e.g., every 5-15 minutes) 2. **Handle errors gracefully** - If a sync fails, retry with the same time window to avoid missing data 3. **Store sync timestamps** - Keep track of your last successful sync to ensure no data gaps 4. **Monitor hasNext** - Always check the `hasNext` field to ensure you've retrieved all available data 5. **Consider webhooks** - For real-time updates, combine periodic syncs with [webhook subscriptions](/general/webhooks) to receive immediate notifications of events like check-ins and membership changes ## Related resources - [Push member data to EGYM](/mms-api-v2/tutorials/member-account-example) - Learn how to create and update member accounts - [API Reference](/mms-api-v2/apis/mms-v2) - Complete endpoint documentation - [Integration Types](/mms-api-v2/tutorials/integration-types) - Understand PUSH vs PULL integration patterns