API Integration Best Practices
Best practices for designing API connections in API Mapper
API Integration Best Practices
Plan Before You Build
Before creating connections, ask yourself:
-
What data do I actually need?
- Don't fetch entire product catalogs if you only need 6 featured items
- Use API parameters to limit data
-
How often does the data change?
- Static content → longer cache times
- Frequently updated → shorter cache times
-
What happens if the API fails?
- Plan for error states
- Consider fallback content
Keep Connections Focused
Good: One connection per use case
Avoid: One giant connection for everything
Why?
- Faster page loads
- Easier to maintain
- More flexible caching per use case
Use Query Parameters Wisely
Fetch only what you need:
Common useful parameters:
| Parameter | Purpose | Example |
|---|---|---|
per_page / limit | Limit results | per_page=10 |
status | Filter by status | status=publish |
orderby | Sort results | orderby=date |
fields | Select specific fields | fields=id,title,price |
Name Connections Clearly
Use descriptive names that explain purpose:
Good names help you:
- Find connections quickly
- Remember what each connection does
- Troubleshoot issues faster
Map Only Needed Fields
Don't map every field the API returns. Map only what you'll actually use in YOOtheme.
Benefits:
- Cleaner field selection in YOOtheme
- Easier to understand at a glance
- Better performance
Example for a product display:
Use Meaningful Field Names
Rename fields to be clear in YOOtheme:
| API Field | Better Name |
|---|---|
images[0].src | Product Image |
price_html | Formatted Price |
short_description | Summary |
_embedded.wp:featuredmedia[0].source_url | Featured Image |
Document Your Connections
Keep notes on:
- What the connection is for
- API credentials location (not the actual keys!)
- Any special configuration
- When/where it's used on the site
Use the Description field in API Mapper for quick reference.
Test Before Going Live
Always test new connections:
- Use the connection tester to verify data
- Check field mappings match expected values
- Test on a staging site first
- Verify error handling - what shows if API fails?
Was this page helpful?