Polling via GET Calls
Retrieve data from MasonHub using periodic API polling
One method for retrieving data from MasonHub is through periodic polling using GET API calls. This approach gives your ERP system control over when and how frequently to check for updates.
Overview
Polling involves making scheduled GET requests to MasonHub’s API endpoints to retrieve the latest information about orders, shipments, inventory, and other business data.
Advantages
- Full control over polling frequency
- Simpler implementation
- Better for batch processing
- No firewall configuration needed
Considerations
- May not be real-time
- Higher API call volume
- Need to manage polling frequency
- Potential for missed updates
Common GET Endpoints
Order Data
Shipment Data
Polling Implementation Patterns
Time-Based Polling
Query for data updated since your last poll:
Status-Based Polling
Focus on specific statuses that require action:
Pagination Handling
Handle large datasets with pagination:
Recommended Polling Frequencies
Order Status Updates
- Frequency: Every 2-5 minutes
- Use case: Critical order tracking
- Data: Order status changes, fulfillment updates
Error Handling & Retry Logic
Rate Limiting
Respect API rate limits to avoid service interruption. Implement exponential backoff for retries.
Data Consistency
Implement mechanisms to ensure you don’t miss data:
Track Last Poll Time
Store the timestamp of your last successful poll
Use Updated Since Filter
Query for data updated since your last poll
Handle Gaps
If polling fails, extend the time window on the next attempt
Validate Data
Check for missing data and implement catch-up mechanisms
Monitoring & Observability
Key Metrics to Track
API Performance
- Response times
- Success rates
- Error rates
- Rate limit hits
Data Quality
- Records processed
- Data freshness
- Missing data detection
- Duplicate handling
Logging Best Practices
Log the following information for troubleshooting:
Integration Examples
Simple Polling Script
Batch Processing
Performance Optimization
Reduce API Calls
Next Steps
Consider implementing callback events (webhooks) for real-time updates on critical data, while using polling for less time-sensitive information.