Get Article Slugs

Retrieve all article slugs from your project for generating static routes in Next.js. This endpoint is primarily used for Next.js generateStaticParams() to pre-render all article pages at build time.

Endpoint

GET https://beatrice.app/api/slugs?token=XXX

Example

GET https://beatrice.app/api/slugs?token=btc_1234567890abcdef

This example retrieves all article slugs belonging to your project.


Response

Returns an array of objects containing slug information for all published articles.

Example Response

[
  {
    "slug": "how-to-improve-seo",
    "updatedAt": "2025-06-28T12:34:56.789Z"
  },
  {
    "slug": "marketing-strategies-2025",
    "updatedAt": "2025-06-27T10:20:30.123Z"
  },
  {
    "slug": "content-marketing-tips",
    "updatedAt": "2025-06-26T15:45:12.456Z"
  }
]

Parameters

Parameter Type Required Description
token query Your project token.

Next.js Integration

Static Site Generation (SSG)

Use this endpoint in your generateStaticParams() function to pre-render all article pages at build time:

// app/blog/[slug]/page.jsx
export async function generateStaticParams() {
  const response = await fetch(
    "https://beatrice.app/api/slugs?token=YOUR_TOKEN"
  );
  const slugs = await response.json();

  return slugs.map((article) => ({
    slug: article.slug,
  }));
}

Incremental Static Regeneration (ISR)

For content that updates frequently, you can combine generateStaticParams() with revalidate:

// app/blog/[slug]/page.jsx
export const revalidate = 3600; // Revalidate every hour

export async function generateStaticParams() {
  const response = await fetch(
    "https://beatrice.app/api/slugs?token=YOUR_TOKEN"
  );
  const slugs = await response.json();

  return slugs.map((article) => ({
    slug: article.slug,
  }));
}

Sitemap Generation

This endpoint is also used for generating sitemaps. See the Sitemap documentation for detailed implementation examples.


Errors

Status Meaning
400 Token required
401 Invalid token
500 Server error

Notes

  • This endpoint only returns published articles (articles with a publishedAt date).
  • The updatedAt field can be used for cache invalidation and last-modified headers.
  • Use this endpoint for static site generation to ensure all your articles are pre-rendered at build time.
  • The response is optimized for performance and only includes essential slug information.