API Server

The API server allows the Contentstack Bridge to be used as an alternative to the Contentstack API. This has a couple of advantages:

  • Querying arguably becomes a lot easier, since the content type is no longer required in a URL query
  • Data can be transformed locally, since it’s stored in a local database
  • Full URLs can be saved, using a parenting system within the content types of entries

All requests require a header Authorization. The value should be equal to the Contentstack delivery token.

Subpages

Endpoints

An overview of all the API endpoints

Response types

A list of possible response types

Subsections of API Server

Endpoints

Get entry by URL

/api/v1/get-entry-by-url

Methods

  • GET

Parameters

  • url (required)
    • The full URL of the entry. This includes the path parts from the parent pages
  • locale (required)
    • The locale of the entry to fetch

Response type

RoutableEntryResponse

Get entry by UID

/api/v1/get-entry-by-uid

Methods

  • GET

Parameters

  • uid (required)
    • The UID of the entry
  • locale (required)
    • The locale of the entry to fetch

Response type

RoutableEntryResponse

Get all content types

/api/v1/content-types

Methods

  • GET

Parameters

Response type

ContentTypesResponse

Get single content type

/api/v1/content-type

Methods

  • GET

Parameters

  • content_type (required)
    • The UID of the content type

Response type

ContentTypeResponse

Get all global fields

/api/v1/global-fields

Methods

  • GET

Parameters

Response type

GlobalFieldsResponse

Get all locales

/api/v1/locales

Methods

  • GET

Parameters

Response type

LocalesResponse

Sync Contentstack data

/api/v1/sync

Methods

  • POST

Parameters

Response type

SyncResponse

Get all translations

/api/v1/translations

Methods

  • GET

Parameters

  • locale (required)
    • The locale of the entry to fetch

Response type

TranslationsResponse

Response types

RoutableEntryResponse

{
  data: { // Will be null if there's an error
    // An array of alternative locales.
    alt_locales: {
      uid: string
      content_type: string
      locale: string
      slug: string
      url: string
    }[]

    // An array of parent entries, to be used when constructing breadcrumbs.
    breadcrumbs: {
        id: string
        uid: string
        title: string
        content_type: string
        locale: string
        slug: string
        url: string
        parent: string // UID of the parent. Will be empty if there's no parent.
        exclude_sitemap: boolean
        published: boolean // Will always be true, since unpublished entries are excluded in the API.
    }[]

    // The entry is directly queried from Contentstack.
    entry: {
      ACL: unknown
      _in_progress: boolean
      _version: number
      content_type: string
      created_at: string // Timestamp string
      created_by: string // UID of the creator
      locale: string
      parent: {
        _content_type_uid: string
        uid: string
      }[]
      publish_details: {
        environment: string // The environment UID
        locale: string
        time: string // Timestamp string
        user: string // The user UID
      }
      tags: string[]
      title: string
      uid: string
      updated_at: string // Timestamp string
      updated_by: string // The user UID
      url: string
      seo?: {
        description?: string
        og_description?: string
        og_title?: string
        title?: string
      }
      // additional options for any other fields
      [key: string]: unknown
    }
  } | null
  error: string | null // Will be null unless there's an error
}

ContentTypesResponse

{
  data: { // Will be null if there's an error
    content_types: {
      DEFAULT_ACL: unknown
      SYS_ACL: unknown
      _version: number
      abilities: {
        create_object: boolean
        delete_all_objects: boolean
        delete_object: boolean
        get_all_objects: boolean
        get_one_object: boolean
        update_object: boolean
      }
      created_at: string // Timestamp string
      description: string
      inbuilt_class: boolean
      last_activity: unknown
      maintain_revisions: boolean
      options: {
        is_page: boolean
        publishable: boolean
        singleton: boolean // Whether or not the content type supports multiple entries
        sub_title: string[]
        title: string
        url_pattern: string
        url_prefix: string
        // additional options for any other fields
        [key: string]: unknown
      }
      schema: {
        data_type: string
        display_name: string
        field_metadata: {
          _default: boolean
          version: number
        }
        mandatory: boolean
        multiple: boolean
        non_localizable: boolean
        uid: string
        unique: boolean
      }[]
      title: string
      uid: string
      updated_at: string // Timestamp string
    }[]
  } | null
  error: string | null // Will be null unless there's an error
}

ContentTypeResponse

{
  data: { // Will be null if there's an error
    content_type: {
      DEFAULT_ACL: unknown
      SYS_ACL: unknown
      _version: number
      abilities: {
        create_object: boolean
        delete_all_objects: boolean
        delete_object: boolean
        get_all_objects: boolean
        get_one_object: boolean
        update_object: boolean
      }
      created_at: string // Timestamp string
      description: string
      inbuilt_class: boolean
      last_activity: unknown
      maintain_revisions: boolean
      options: {
        is_page: boolean
        publishable: boolean
        singleton: boolean // Whether or not the content type supports multiple entries
        sub_title: string[]
        title: string
        url_pattern: string
        url_prefix: string
        // additional options for any other fields
        [key: string]: unknown
      }
      schema: {
        data_type: string
        display_name: string
        field_metadata: {
          _default: boolean
          version: number
        }
        mandatory: boolean
        multiple: boolean
        non_localizable: boolean
        uid: string
        unique: boolean
      }[]
      title: string
      uid: string
      updated_at: string // Timestamp string
    }
  } | null
  error: string | null // Will be null unless there's an error
}

GlobalFieldsResponse

{
  data: { // Will be null if there's an error
    global_fields: {
      _version: number
      created_at: string // Timestamp string
      description: string
      inbuilt_class: boolean
      last_activity: unknown
      maintain_revisions: boolean
      schema: {
        data_type: string
        display_name: string
        error_messages: {
          format: string
        }
        field_metadata: {
          default_value: string
          description: string
          version: number
        }
        format: string
        mandatory: boolean
        multiple: boolean
        non_localizable: boolean
        uid: string
        unique: boolean
      }[]
      title: string
      uid: string
      updated_at: string // Timestamp string
    }[]
  } | null
  error: string | null // Will be null unless there's an error
}

LocalesResponse

{
  data: { // Will be null if there's an error
    locales: {
      ACL: unknown[]
      _version: number
      code: string
      created_at: string // Timestamp string
      created_by: string // UID of the creator
      fallback_locale: string
      name: string
      uid: string
      updated_at: string // Timestamp string
      updated_by: string // UID of the creator
    }[]
  } | null
  error: string | null // Will be null unless there's an error
}

SyncResponse

{
  error: string | null; // Will be null unless there's an error
}

TranslationsResponse

{
  data: Record<string, string> | null; // Will be null if there's an error
  error: string | null; // Will be null unless there's an error
}