Collections

List a Collection's Pens

The key owner's own Pens in the Collection, sorted by the Pens' own timestamps.

get/v2/collections/{id}/pens

Request

  • Base URL
    https://api.codepen.io
  • Auth
    • HTTP bearer
    • or API key in header X-API-Key

Query parameters

pageinteger

The page, from 1.

per_pageinteger

Items per page. A value over 100 is reduced to 100, not refused.

sort'created' | 'updated'

The order: by creation or update time.

direction'asc' | 'desc'

desc, the default, lists newest first.

Response

A page of Pens.

access'Public' | 'Private' | 'Protected' | 'Collaborators' required

Public; Private (not listed on the site; anyone with the link can view it); Protected (private and password protected); Collaborators (private and for collaborators only). Anything but Public needs a PRO plan.

created_atstring date-time required
descriptionstring required
editor'Classic' | 'V2' required

V2, or Classic for a Pen made in the classic editor, which is read-only through the API.

idstring required

The cpid, or the hashid for a Pen made in the classic editor.

loves_countinteger required
passwordstring nullable required

Write-only, so always null.

popularityinteger required
tagsstring[] required
templateboolean required
titlestring required
updated_atstring date-time required
views_countinteger required

Views as the site shows them, tallied in batches, so it can trail by a few minutes.

Example response

[
  {
    "build": {
      "files": [
        {
          "name": "app.js",
          "path": "/src/app.js"
        }
      ]
    },
    "saved_version": {
      "build": {
        "files": [
          {
            "name": "app.js",
            "path": "/src/app.js"
          }
        ]
      },
      "files": [
        {
          "name": "app.js",
          "path": "/src/app.js"
        }
      ]
    }
  }
]

Changes

No recorded changes to this operation across all 1 revision of this API.