Skip to main content
Make sure locales are configured first. See Setting Up Locales.

Fetching localized content via API

After enabling Localization, you will need to update all API calls to include the locale parameter. The locale parameter tells the ButterCMS API which localized version of your content to return.

API endpoint patterns

Single Page

Multiple Pages

Page Types

Collections

Blog Posts

Single Blog Post

Blog Post Search

JavaScript / Node.js examples

Basic setup

Fetching a single Page

Fetching multiple Pages

Fetching Collections

Dynamic locale selection

Python examples

Basic setup

Fetching a single Page

Fetching multiple Pages

Fetching Collections

PHP / Laravel examples

Controller setup

Fetching Collections

Ruby / Rails examples

Basic setup

Fetching a single Page

Fetching Collections

cURL examples

Fetch single Page

Fetch multiple Pages

Fetch Collections

Next.js App Router example

Dynamic locale routing

Handling locale in frontend frameworks

Next.js internationalized routing

Configure next.config.js for locale support:
Then use the locale in your data fetching:

Previewing localized content

Use the preview parameter to fetch unpublished (draft) content in a specific locale.

Preview mode

To preview unpublished localized content, include the preview parameter:

Setting up preview URLs

Configure locale-specific preview URLs in your frontend:

Handling missing locale content

When content doesn’t exist in a requested locale, you have several options:

Option 1: fallback to default locale

Option 2: show locale not available message

Option 3: redirect to available locale

For unpublishing and deleting localized content, see Publishing Localized Content.

Best practices

Error handling

Always handle cases where content might not exist in a requested locale:

Caching considerations

  • Cache responses per locale
  • Invalidate cache when content is updated
  • Consider using ISR (Incremental Static Regeneration) in Next.js

Performance tips

  • Use the fields parameter to request only needed fields
  • Implement pagination for large collections
  • Pre-fetch content for common locale switches