Skip to main content
GET
/
api
/
v1
/
tokensets
/
{id}
/
modes
/
{modeId}
/
tokens
List Tokens
curl --request GET \
  --url https://app.tokencraft.dev/api/v1/api/v1/tokensets/{id}/modes/{modeId}/tokens \
  --header 'Authorization: Bearer <token>'

List Tokens

Retrieves all design tokens for a specific mode within a tokenset.

Endpoint

GET /api/v1/tokensets/{id}/modes/{modeId}/tokens

Request

Path Parameters

ParameterTypeRequiredDescription
idstringYesTokenset ID
modeIdstringYesMode ID

Response

Status: 200 OK
{
  "mode": {
    "id": "mode-light",
    "name": "Light",
    "is_default": true
  },
  "tokens": [
    {
      "id": "token-1",
      "tokenset_id": "tokenset-123",
      "mode_id": "mode-light",
      "name": "colors.primary.500",
      "type": "color",
      "value": "#3b82f6",
      "description": "Primary brand color",
      "alias_to": null,
      "created_at": "2025-01-15T10:00:00Z",
      "updated_at": "2025-01-15T10:00:00Z"
    },
    {
      "id": "token-2",
      "tokenset_id": "tokenset-123",
      "mode_id": "mode-light",
      "name": "spacing.base",
      "type": "dimension",
      "value": "16px",
      "description": "Base spacing unit",
      "alias_to": null,
      "created_at": "2025-01-15T10:10:00Z",
      "updated_at": "2025-01-15T10:10:00Z"
    }
  ],
  "total": 2
}

Token Object

FieldTypeDescription
idstringUnique token identifier
tokenset_idstringParent tokenset ID
mode_idstringParent mode ID
namestringToken name (dot notation)
typestringToken type (color, dimension, etc.)
valueanyToken value
descriptionstring|nullOptional description
alias_tostring|nullReference to another token
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp

Supported Token Types

  • color - Color values
  • dimension - Sizes and spacing
  • fontFamily - Font families
  • fontWeight - Font weights
  • fontSize - Font sizes
  • lineHeight - Line heights
  • letterSpacing - Letter spacing
  • duration - Animation durations
  • cubicBezier - Easing functions
  • number - Numeric values
  • strokeStyle - Stroke styles
  • border - Border definitions
  • transition - Transition definitions
  • shadow - Shadow effects
  • gradient - Gradient definitions
  • typography - Complete typography definitions

Examples

curl -H "Authorization: Bearer dtk_your_token_here" \
  https://app.tokencraft.dev/api/v1/tokensets/tokenset-123/modes/mode-light/tokens

Use Cases

1. Display Token List

Show all tokens in a UI:
function TokenList({ tokens }) {
  return (
    <div>
      {tokens.map(token => (
        <div key={token.id}>
          <h3>{token.name}</h3>
          <p>{token.type}: {token.value}</p>
          {token.description && <p>{token.description}</p>}
        </div>
      ))}
    </div>
  );
}

2. Generate Documentation

Create auto-generated docs:
async function generateDocs(tokensetId, modeId) {
  const { tokens } = await getTokens(tokensetId, modeId);
  
  const byCategory = tokens.reduce((acc, token) => {
    const [category] = token.name.split('.');
    if (!acc[category]) acc[category] = [];
    acc[category].push(token);
    return acc;
  }, {});
  
  return Object.entries(byCategory).map(([category, tokens]) => ({
    category,
    tokens
  }));
}

3. Search Tokens

Filter by name or type:
async function searchTokens(tokensetId, modeId, query) {
  const { tokens } = await getTokens(tokensetId, modeId);
  
  return tokens.filter(token =>
    token.name.toLowerCase().includes(query.toLowerCase()) ||
    token.description?.toLowerCase().includes(query.toLowerCase())
  );
}

Next Steps