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:

  1. 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
  2. How often does the data change?

    • Static content → longer cache times
    • Frequently updated → shorter cache times
  3. What happens if the API fails?

    • Plan for error states
    • Consider fallback content

Keep Connections Focused

Good: One connection per use case

✓ "Homepage Featured Products" (6 products)
✓ "Product Category: Electronics" (12 products)
✓ "Sale Items" (filtered by sale_price)

Avoid: One giant connection for everything

✗ "All Products" (1000+ products)

Why?

  • Faster page loads
  • Easier to maintain
  • More flexible caching per use case

Use Query Parameters Wisely

Fetch only what you need:

# Good - specific request
/products?per_page=6&status=publish&featured=true

# Bad - fetch everything
/products

Common useful parameters:

ParameterPurposeExample
per_page / limitLimit resultsper_page=10
statusFilter by statusstatus=publish
orderbySort resultsorderby=date
fieldsSelect specific fieldsfields=id,title,price

Name Connections Clearly

Use descriptive names that explain purpose:

✓ "Homepage - Latest Blog Posts"
✓ "Product Grid - Sale Items"
✓ "Footer - Contact Info"

✗ "API 1"
✗ "Products"
✗ "Test"

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:

✓ Map: name, price, image, link
✗ Skip: internal_id, created_at, meta_data, variations[]

Use Meaningful Field Names

Rename fields to be clear in YOOtheme:

API FieldBetter Name
images[0].srcProduct Image
price_htmlFormatted Price
short_descriptionSummary
_embedded.wp:featuredmedia[0].source_urlFeatured 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:

  1. Use the connection tester to verify data
  2. Check field mappings match expected values
  3. Test on a staging site first
  4. Verify error handling - what shows if API fails?

Was this page helpful?

On this page