Storyden

Marks

Marks are flexible shapeshifting identifiers for use in slugs and API calls.

Marks are the way resources are identified on the Storyden API.

The problem

This is ugly, and not SEO friendly:

/t/d7la96g5o6lqd95sms0g

This is not necessarily uniqueness friendly, and given slugs are generated from titles, it's not totally unlikely two threads could result in the same slug:

/t/scribblers-now-for-up-to-100-players-at-once

The solution

You've probably seen this on many other platforms, a unique identifier followed by an SEO-friendly URL slug, derived from the post's title:

/t/d7la96g5o6lqd95sms0g-scribblers-now-for-up-to-100-players-at-once

How they're used

Storyden resources will always provide an ID and a slug in the payload. The ID is an xid format ID, and the slug is a URL-friendly version of the title.

When reading data from the API, you'll almost always have these two pieces of information. However there are cases where only an ID is provided, such as with content references.

Whenever a URL parameter or field on the API uses a mark, it means the ID or the full mark are interchangeable. This allows for flexibility in how you identify resources.

For example, the post at makeroom.club/t/d7la96g5o6lqd95sms0g-scribblers-now-for-up-to-100-players-at-once may be addressed via:

  • d7la96g5o6lqd95sms0g-scribblers-now-for-up-to-100-players-at-once the full slug
  • d7la96g5o6lqd95sms0g just the ID

Technical details

When a request comes in with a mark, it's parsed into a data structure containing either the ID or the full mark. This is then turned into a predicate at the resource layer during queries. This means there are no OR clauses or multiple queries to handle both cases.

On this page