Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Api

Hierarchy

  • Api

Implements

Index

Constructors

constructor

Properties

accessToken

accessToken: string

apiCache

apiCache: IApiCache

apiCacheKey

apiCacheKey: string

apiDataTTL

apiDataTTL: number

bookmarks

bookmarks: string[]

data

data: any

experiments

experiments: IExperiments

forms

forms: IForm[]

oauthInitiate

oauthInitiate: string

oauthToken

oauthToken: string

quickRoutes

quickRoutes: any

refs

refs: Ref[]

req

req: any

requestHandler

requestHandler: IRequestHandler

tags

tags: string[]

types

types: object

url

url: string

Methods

currentExperiment

everything

form

  • Returns a useable form from its id, as described in the RESTful description of the API. For instance: api.form("everything") works on every repository (as "everything" exists by default) You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit()

    Parameters

    • formId: string

    Returns ISearchForm | null

get

  • get(callback: function): Promise<IApi>
  • Fetches data used to construct the api client, from cache if it's present, otherwise from calling the prismic api endpoint (which is then cached).

    Parameters

    • callback: function
        • (err: Error | null, value?: any, xhr?: any, ttl?: undefined | number): void
        • Parameters

          • err: Error | null
          • Optional value: any
          • Optional xhr: any
          • Optional ttl: undefined | number

          Returns void

    Returns Promise<IApi>

getBookmark

  • getBookmark(bookmark: string, options: any, callback: function): Promise<any>
  • Retrieve the document with the given bookmark

    Parameters

    • bookmark: string
    • options: any
    • callback: function
        • (err: Error | null, response?: any): void
        • Parameters

          • err: Error | null
          • Optional response: any

          Returns void

    Returns Promise<any>

getByID

  • getByID(id: string, options: any, callback: function): Promise<any>
  • Retrieve the document with the given id

    Parameters

    • id: string
    • options: any
    • callback: function
        • (err: Error | null, response?: any): void
        • Parameters

          • err: Error | null
          • Optional response: any

          Returns void

    Returns Promise<any>

getByIDs

  • getByIDs(ids: string[], options: any, callback: function): Promise<IApiResponse>
  • Retrieve multiple documents from an array of id

    Parameters

    • ids: string[]
    • options: any
    • callback: function
        • (err: Error | null, response?: any): void
        • Parameters

          • err: Error | null
          • Optional response: any

          Returns void

    Returns Promise<IApiResponse>

getByUID

  • getByUID(type: string, uid: string, options: any, callback: function): Promise<any>
  • Retrieve the document with the given uid

    Parameters

    • type: string
    • uid: string
    • options: any
    • callback: function
        • (err: Error | null, response?: any): void
        • Parameters

          • err: Error | null
          • Optional response: any

          Returns void

    Returns Promise<any>

getNextPage

  • getNextPage(nextPage: number, callback: function): PromiseLike<IApiResponse>
  • Parameters

    • nextPage: number
    • callback: function
        • (err: Error | null, results: IApiResponse | null, xhr?: any): void
        • Parameters

          • err: Error | null
          • results: IApiResponse | null
          • Optional xhr: any

          Returns void

    Returns PromiseLike<IApiResponse>

getQuickRoutes

  • getQuickRoutes(callback: function): Promise<any>
  • Retrieve quick routes definitions

    Parameters

    • callback: function
        • (err: Error, data: any, xhr: any): void
        • Parameters

          • err: Error
          • data: any
          • xhr: any

          Returns void

    Returns Promise<any>

getSingle

  • getSingle(type: string, options: any, callback: function): Promise<any>
  • Retrieve the singleton document with the given type

    Parameters

    • type: string
    • options: any
    • callback: function
        • (err: Error | null, response?: any): void
        • Parameters

          • err: Error | null
          • Optional response: any

          Returns void

    Returns Promise<any>

master

  • master(): string
  • The ID of the master ref on this prismic.io API. Do not use like this: searchForm.ref(api.master()). Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.

    Returns string

Private parse

  • parse(data: any): object
  • Parses and returns the /api document. This is for internal use, from outside this kit, you should call Prismic.Api()

    Parameters

    • data: any

      The JSON document responded on the API's endpoint

    Returns object

    • The Api object that can be manipulated

previewSession

  • previewSession(token: string, linkResolver: function, defaultUrl: string, callback: function): PromiseLike<string>
  • Return the URL to display a given preview

    Parameters

    • token: string
    • linkResolver: function
        • (ctx: any): string
        • Parameters

          • ctx: any

          Returns string

    • defaultUrl: string
    • callback: function
        • (err: Error | null, url?: any, xhr?: any): void
        • Parameters

          • err: Error | null
          • Optional url: any
          • Optional xhr: any

          Returns void

    Returns PromiseLike<string>

query

  • Query the repository

    Parameters

    • q: string | IPredicate | IPredicate[]
    • optionsOrCallback: any | function
    • cb: function
        • (err: Error | null, response?: any): void
        • Parameters

          • err: Error | null
          • Optional response: any

          Returns void

    Returns Promise<IApiResponse>

queryFirst

  • queryFirst(q: string | IPredicate[] | IPredicate, optionsOrCallback: any | function, cb: function): Promise<any>
  • Retrieve the document returned by the given query

    Parameters

    • q: string | IPredicate[] | IPredicate
    • optionsOrCallback: any | function
    • cb: function
        • (err: Error | null, response?: any): void
        • Parameters

          • err: Error | null
          • Optional response: any

          Returns void

    Returns Promise<any>

quickRoutesEnabled

  • quickRoutesEnabled(): boolean

ref

  • ref(label: string): string | null
  • Returns the ref ID for a given ref's label. Do not use like this: searchForm.ref(api.ref("Future release label")). Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.

    Parameters

    • label: string

    Returns string | null

refresh

  • Cleans api data from the cache and fetches an up to date copy.

    Parameters

    • callback: function

      Optional callback function that is called after the data has been refreshed

        • (err: Error | null | undefined, data: any, xhr: any): void
        • Parameters

          • err: Error | null | undefined
          • data: any
          • xhr: any

          Returns void

    Returns PromiseLike<IApiResponse>

request

  • request(url: string, callback: function): PromiseLike<IApiResponse>
  • Fetch a URL corresponding to a query, and parse the response as a Response object

    Parameters

    • url: string
    • callback: function
        • (err: Error | null, results: IApiResponse | null, xhr?: any): void
        • Parameters

          • err: Error | null
          • results: IApiResponse | null
          • Optional xhr: any

          Returns void

    Returns PromiseLike<IApiResponse>

response

Generated using TypeDoc