Class Contentstack


  • public class Contentstack
    extends Object
    The Content Delivery API is used to retrieve content from your Contentstack account and deliver it to your web or mobile properties. If you are looking for APIs to manage content, you should use the Content Management API

    Our APIs serve content via a powerful and robust content delivery network (CDN). Multiple datacenters around the world store a cached copy of your content. When a page request is made, the content is delivered to the user from the nearest server. This greatly accelerates content delivery and reduces latency.

    • Method Detail

      • stack

        public static Stack stack​(String stackApiKey,
                                  String deliveryToken,
                                  String environment)
                           throws IllegalAccessException
        A stack is a space that stores the content of a project (a web or mobile property). Within a stack, you can create content structures, content entries, users, etc. related to the project.
        Authenticates the stack api key of your stack.
        Find Your Stack Credentials from Contentstack .
        Parameters:
        stackApiKey - The API Key is a unique key assigned to each stack.
        deliveryToken - The Delivery Token is a read-only credential that you can create for different environments of your stack
        environment - the environment for the stack
        Returns:
        the stack
        Throws:
        IllegalAccessException - the illegal access exception

        Example

                                                                                                      {
                                                                                                          @Code
                                                                                                          Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
                                                                                                      }
        
                                                                                                      
      • stack

        public static Stack stack​(String stackApiKey,
                                  String deliveryToken,
                                  String environment,
                                  Config config)
                           throws IllegalAccessException
        A stack is a space that stores the content of a project (a web or mobile property). Within a stack, you can create content structures, content entries, users, etc. related to the project.
        Parameters:
        stackApiKey - The API Key is a unique key assigned to each stack.
        deliveryToken - The Delivery Token is a read-only credential that you can create for different environments of your stack
        environment - the environment for the stack
        config - the config
        Returns:
        the stack
        Throws:
        IllegalAccessException - the illegal access exception Example

        { @Code Stack stack = contentstack.Stack("apiKey", "deliveryToken", "environment"); }

      • getContentstackEndpoint

        public static String getContentstackEndpoint​(String region,
                                                     String service)
        Returns the Contentstack API URL for the given region and service.

        Delegates to Endpoint.getContentstackEndpoint(String, String) — provided as a convenience so callers can reach endpoint resolution through the same top-level class they use to create stacks.

        Parameters:
        region - region ID or alias (e.g. "na", "eu", "azure-na")
        service - service key (e.g. "contentDelivery", "contentManagement")
        Returns:
        full URL including https:// scheme
        Throws:
        IllegalArgumentException - if the region or service is not recognised
      • getContentstackEndpoint

        public static String getContentstackEndpoint​(String region,
                                                     String service,
                                                     boolean omitHttps)
        Returns the Contentstack API URL for the given region and service, optionally stripping the https:// scheme.
        Parameters:
        region - region ID or alias
        service - service key
        omitHttps - when true, returns the bare host without https://
        Returns:
        URL or bare host
        Throws:
        IllegalArgumentException - if the region or service is not recognised
      • getContentstackEndpoints

        public static Map<String,​String> getContentstackEndpoints​(String region)
        Returns all service endpoints for the given region as an ordered map of service key to URL.
        Parameters:
        region - region ID or alias
        Returns:
        map of service key → full URL
        Throws:
        IllegalArgumentException - if the region is not recognised
      • getContentstackEndpoints

        public static Map<String,​String> getContentstackEndpoints​(String region,
                                                                        boolean omitHttps)
        Returns all service endpoints for the given region, optionally stripping the https:// scheme from every URL.
        Parameters:
        region - region ID or alias
        omitHttps - when true, returns bare hosts without https://
        Returns:
        map of service key → URL or bare host
        Throws:
        IllegalArgumentException - if the region is not recognised