Developers

Contents

Summary of contents endpoints

For pages:

For languages:

For articles:

For elements:

List all available contents for the current parent

By default, this requests returns a list of all contents for the current parent (ordered by position).

This endpoint also allows anonymous access that returns only content for published parent objects
(published articles, non private pages).

GET /admin/api/pages/1/contents

Example response (authenticated request):

Status: 200 OK
[
  {
    "id": 1,
    "name": "body",
    "position": 1,
    "content_type": "form",
    "created_at": "2014-01-13T09:19:05.000Z",
    "updated_at": "2014-01-13T09:19:05.000Z",
    "url": "http://helloworld.voog.co/admin/api/pages/1/contents/1",
    "relocate_url": "http://helloworld.voog.co/admin/api/pages/1/contents/1/relocate",
    "language": {
      "id": 1,
      "code": "en",
      "title": "ENG",
      "created_at": "2014-01-13T09:19:04.000Z",
      "updated_at": "2014-01-13T09:19:04.000Z",
      "url": "http://helloworld.voog.co/admin/api/languages/1"
    },
    "parent": {
      "id": 1,
      "title": "Home Page",
      "type": "page",
      "created_at": "2014-01-13T09:19:04.000Z",
      "updated_at": "2014-01-13T09:19:04.000Z",
      "public_url": "http://helloworld.voog.co/en",
      "url": "http://helloworld.voog.co/admin/api/pages/1"
    },
    "form": {
      "id": 1,
      "created_at": "2014-01-13T09:25:22.000Z",
      "updated_at": "2014-01-13T09:26:17.000Z",
      "url": "http://helloworld.voog.co/admin/api/forms/1",
      "title": "Page title",
      "description": null,
      "fields": [],
      "submit_emails": null,
      "submit_label": "Submit",
      "submit_email_subject": null,
      "submit_action": null,
      "submit_success_message": null,
      "submit_success_address": null,
      "submit_failure_message": null
    }
  }, {
    "id": 2,
    "name": "slogan",
    "position": 1,
    "content_type": "text",
    "created_at": "2014-01-13T09:19:05.000Z",
    "updated_at": "2014-01-13T09:19:05.000Z",
    "url": "http://helloworld.voog.co/admin/api/pages/1/contents/2",
    "relocate_url": "http://helloworld.voog.co/admin/api/pages/1/contents/2/relocate",
    "language": {
      "id": 1,
      "code": "en",
      "title": "ENG",
      "created_at": "2014-01-13T09:19:04.000Z",
      "updated_at": "2014-01-13T09:19:04.000Z",
      "url": "http://helloworld.voog.co/admin/api/languages/1"
    },
    "parent": {
      "id": 1,
      "title": "Home Page",
      "type": "page",
      "created_at": "2014-01-13T09:19:04.000Z",
      "updated_at": "2014-01-13T09:19:04.000Z",
      "public_url": "http://helloworld.voog.co/en",
      "url": "http://helloworld.voog.co/admin/api/pages/1"
    },
    "text": {
      "id": 1,
      "created_at": "2014-01-13T09:19:04.000Z",
      "updated_at": "2014-01-13T09:19:04.000Z",
      "url": "http://helloworld.voog.co/admin/api/texts/1",
      "body": "<h3>A better way to create a website</h3>"
    }
  }
]

Example response (anonymous request):

Status: 200 OK
[
  {
    "id": 1,
    "name": "body",
    "position": 1,
    "content_type": "form",
    "language": {
      "id": 1,
      "code": "en",
      "title": "ENG"
    },
    "parent": {
      "id": 1,
      "title": "Home Page",
      "type": "page",
      "public_url": "http://helloworld.voog.co/en"
    },
    "form": {
      "title": "Page title",
      "fields": [],
      "submit_label": "Submit"
    }
  }, {
    "id": 2,
    "name": "slogan",
    "position": 1,
    "content_type": "text",
    "language": {
      "id": 1,
      "code": "en",
      "title": "ENG"
    },
    "parent": {
      "id": 1,
      "title": "Home Page",
      "type": "page",
      "public_url": "http://helloworld.voog.co/en"
    },
    "text": {
      "body": "<h3>A better way to create a website</h3>"
    }
  }
]

Parameters

  • per_page - elements per response (default: 50; maximum: 250).
  • page - requested page (default: 1).
  • name - content area name (e.g. slogan). Returns only contents for given content area.
  • content_type - content type (e.g. form). Returns only content matching to given type. Allowed types are: text, form, gallery and content_partial

Filter attributes

Read more about filters.

  • Object content attributes: id, parent_id, language_id, content_id, content_type, page_id, page_type, name, position, created_at, updated_at.

Create a new content for the current parent

POST /admin/api/pages/1/contents

Example data:

{
  "name": "body",
  "content_type": "gallery"
}

Example response:

Status: 201 Created
{
  "id": 3,
  "name": "body",
  "position": 2,
  "content_type": "gallery",
  "created_at": "2014-01-13T10:00:05.000Z",
  "updated_at": "2014-01-13T10:00:05.000Z",
  "url": "http://helloworld.voog.co/admin/api/pages/1/contents/3",
  "relocate_url": "http://helloworld.voog.co/admin/api/pages/1/contents/3/relocate",
  "language": {
    "id": 1,
    "code": "en",
    "title": "ENG",
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "url": "http://helloworld.voog.co/admin/api/languages/1"
  },
  "parent": {
    "id": 1,
    "title": "Home Page",
    "type": "page",
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "public_url": "http://helloworld.voog.co/en",
    "url": "http://helloworld.voog.co/admin/api/pages/1"
  },
  "gallery": {
    "id": 1,
    "title": "",
    "kind": "squares",
    "settings": {},
    "created_at": "2014-01-13T10:00:05.000Z",
    "updated_at": "2014-01-13T10:00:05.000Z",
    "url": "http://helloworld.voog.co/admin/api/media_sets/1"
  }
}

Parameters

Required minimum set of parameters are:

  • name - name of the content are where content is added.

Optional parameters:

  • content_type - content type for new content (e.g. text). Allowed types (default is text):

Request parameters

  • after - id of existing content in same content area (e.g. /admin/api/pages/1/contents?after=1). If not present then new content area is placed to end of content areas in scope of the given name.

Get data for a single content

GET /admin/api/pages/1/contents/1

Example request:

GET http://helloworld.voog.co/admin/api/pages/1/contents/2

Example response:

Status: 200 OK
{
  "id": 2,
  "name": "slogan",
  "position": 1,
  "content_type": "text",
  "created_at": "2014-01-13T09:19:05.000Z",
  "updated_at": "2014-01-13T09:19:05.000Z",
  "url": "http://helloworld.voog.co/admin/api/pages/1/contents/2",
  "relocate_url": "http://helloworld.voog.co/admin/api/pages/1/contents/2/relocate",
  "language": {
    "id": 1,
    "code": "en",
    "title": "ENG",
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "url": "http://helloworld.voog.co/admin/api/languages/1"
  },
  "parent": {
    "id": 1,
    "title": "Home Page",
    "type": "page",
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "public_url": "http://helloworld.voog.co/en",
    "url": "http://helloworld.voog.co/admin/api/pages/1"
  },
  "text": {
    "id": 1,
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "url": "http://helloworld.voog.co/admin/api/texts/1",
    "body": "<h3>A better way to create a website</h3>"
  }
}

Example responses by content type:

Content type is text:

{
  "...": "...",
  "content_type": "text",
  "text": {
    "id": 1,
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "url": "http://helloworld.voog.co/admin/api/texts/1",
    "body": "<h3>A better way to create a website</h3>"
  }
}

Content type is form:

{
  "...": "...",
  "content_type": "form",
  "form": {
    "id": 1,
    "created_at": "2014-01-13T09:25:22.000Z",
    "updated_at": "2014-01-13T09:26:17.000Z",
    "url": "http://helloworld.voog.co/admin/api/forms/1",
    "title": "Page title",
    "description": null,
    "fields": [],
    "submit_emails": null,
    "submit_label": "Submit",
    "submit_email_subject": null,
    "submit_action": null,
    "submit_success_message": null,
    "submit_success_address": null,
    "submit_failure_message": null
  }
}

Content type is gallery:

{
  "...": "...",
  "content_type": "gallery",
  "gallery": {
    "id": 1,
    "created_at": "2014-01-13T10:00:05.000Z",
    "updated_at": "2014-01-13T10:00:05.000Z",
    "url": "http://helloworld.voog.co/admin/api/media_sets/1",
    "title": "Page title",
    "kind": "squares",
    "settings": {},
    "assets": [
      {
        "title": "",
        "position": 1,
        "created_at": "2014-01-13T09:33:05.000Z",
        "updated_at": "2014-01-13T09:33:05.000Z",
        "id": 179,
        "filename": "my-photo.png",
        "content_type": "image/png",
        "size": 124076,
        "extension": "png",
        "type": "image",
        "width": 864,
        "height": 359,
        "url": "http://helloworld.voog.co/admin/api/assets/1",
        "original_url": "http://media.voog.com/0000/0000/0001/photos/my-photo.png",
        "sizes": [
          {
            "filename": "my-photo_block.png",
            "content_type": "image/png",
            "size": 66929,
            "thumbnail": "block",
            "width": 500,
            "height": 208,
            "original_url": "http://media.voog.com/0000/0000/0001/photos/my-photo_block.png"
          },
          {
            "filename": "my-photo_medium.jpg",
            "content_type": "image/jpeg",
            "size": 2940,
            "thumbnail": "medium",
            "width": 150,
            "height": 62,
            "original_url": "http://media.voog.com/0000/0000/0001/photos/my-photo_medium.jpg"
          }
        ]
      }
    ],
    "add_assets_url": "http://helloworld.voog.co/admin/api/media_sets/1/add_assets"
  }
}

Content type is content_partial:

{
  "...": "...",
  "content_type": "content_partial",
  "content_partial": {
    "id": 1,
    "content_type": "video",
    "created_at": "2014-05-30T10:22:04.000Z",
    "updated_at": "2014-05-30T10:22:04.000Z",
    "url": "http://helloworld.voog.co/admin/api/content_partials/1",
    "body": "<iframe scrolling=\"no\" style=\"width: 436px; height: 358.033px;\" src=\"http://www.youtube.com/embed/jTv3wWQDDgQ\"></iframe>",
    "metainfo": {
      "type": "video"
    }
  }
}

Relocate a content

PUT /admin/api/pages/1/contents/1/relocate
PUT /admin/api/pages/1/contents/1/move (alias)

Reorders or moves content inside and between content areas and parent objects.

Example request:

PUT http://helloworld.voog.co/admin/api/pages/1/contents/2?before=1

Example response:

Status: 201 Created
{
  "id": 2,
  "name": "body",
  "position": 1,
  "content_type": "text",
  "created_at": "2014-01-13T09:19:05.000Z",
  "updated_at": "2014-01-13T09:19:05.000Z",
  "url": "http://helloworld.voog.co/admin/api/pages/1/contents/2",
  "relocate_url": "http://helloworld.voog.co/admin/api/pages/1/contents/2/relocate",
  "language": {
    "id": 1,
    "code": "en",
    "title": "ENG",
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "url": "http://helloworld.voog.co/admin/api/languages/1"
  },
  "parent": {
    "id": 1,
    "title": "Home Page",
    "type": "page",
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "public_url": "http://helloworld.voog.co/en",
    "url": "http://helloworld.voog.co/admin/api/pages/1"
  },
  "text": {
    "id": 1,
    "created_at": "2014-01-13T09:19:04.000Z",
    "updated_at": "2014-01-13T09:19:04.000Z",
    "url": "http://helloworld.voog.co/admin/api/texts/1"
  }
}

Parameters

  • name - content area name.
  • before - existing content id.
  • after - existing content id.
  • parent_id - parent location id.
  • parent_type - parent location type (allowed: page, language and article).

Allowed combinations:

  • name - moves current content to end of given area (under same parent) (e.g. ?name="slogan").
  • before - moves current content before given content (may locate under different parent) (e.g. ?before=2).
  • after - moves current content after given content (may locate under different parent) (e.g. ?after=2).
  • name, parent_id and parent_type - moves current content to end of given area under given parent (e.g. ?name="body"&parent_id=1&parent_type="language").

Remove a content

DELETE /admin/api/pages/1/contents/3

This request deletes the content and content related object from the database.

The only exception is form object that is not deleted on content destroy. Form object remains into the database until it's deleted using form destroy action.

Example request:

DELETE http://helloworld.voog.co/admin/api/pages/1/contents/3

Example response:

Status: 204 No Content