Skip to content

API-JSON Connector

Prerequisites

  1. The JSON returned by the API must follow one of the two formats below:
jsx
[
  {
    "title": "my title",
    "content": "my content",
    {...},
    [...]
  },
  {
    "title": "my title 2",
    "content": "my content 2",
    {...},
    [...]
  }
]

or as below:

jsx
[
  {

    "info": [
      {
	      "title": "my title",
        "content": "my content"
      }
    ]
  },
  ...
  ]

Connector Configuration

The API-JSON connector is an advanced connector that automatically indexes content coming from a public JSON API. It allows you to create a customizable document based on data coming from a JSON API.

Field nameFormat / TypeRequiredComment
URLsList of texts / URLThe URL or URLs of the API to index
Document FormatFree text (Mustache + Markdown template)Allows you to create a file template, supporting Markdown and the Mustache format
URL FormatFree text (Mustache template)Allows you to create a template for the page's source URL, supporting Markdown and the Mustache format
Target Array PathFree textAllows you to target an array, each object of which will become a document

💡 Fields marked ✅ are required for the connector to work.

Setup

Building the document template (Document Format)

Thanks to the Mustache template, we can build our future document from the fields returned by the API.

Example of a simple template:

jsx
my title :  {{{title}}}
page content : {{{content}}}
description : {{{xxxx.xxxx.description}}}

Targeting a nested array (Target Array Path)

We can also target an array nested in an API response rather than the root array. Example: I want to retrieve the paragraphs from the following response:

jsx
[
  {
    "title": "my-title",
    "content": "my content",
    {...},
    "paragraphes"[...]
  },
  {
    "title": "my-title-2",
    "content": "my content 2",
    {...},
    "paragraphes"[...]
  }
]

I can put paragraphes in the Target Array Path field. The connector will create a document for each paragraph.

Building the source URL template (URL Format)

For the source URL, the same logic applies as for the template; we can use {{{}}}

example:

jsx
https://mySite.com/{{{tite}}}
//https://mySite.com/my-title

To learn more about Mustache templates ⇒ https://mustache.github.io/mustache.5.html

How the Connector Works

  • The connector queries each configured URL and retrieves the JSON returned by the API.
  • It creates a document for each element of the targeted array (the root array by default, or the array designated by Target Array Path).
  • The content of each document is generated from the Mustache template entered in Document Format.
  • The source URL of each document, if provided, is generated from the Mustache template entered in URL Format.

FAQ

How do I configure my connector?

Enter one or more URLs of an API that returns JSON containing arrays that the connector can loop over (see the two accepted formats in the Prerequisites section above).

Using the Mustache template entered in the Document Format field, you then build the document that will be created for each element of the array. If the data you want to index is located in a nested array rather than at the root of the response, use the Target Array Path field to target it. You can also generate the source URL of each document using a Mustache template entered in the URL Format field.

See the Setup section above for details and examples of each of these templates.