Skip to content

API-JSON Connector

Prerequisites

an API that returns JSON in the following format:

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

or

jsx
[
  {

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

FAQ

How to configure my connector?

A URL or URLs of an API that returns JSON with arrays that can be looped over.

Example of API response:

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

Thanks to the Mustache template, we can build our future document.

Example of a simple template:

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

We can also target an array in an API response.

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.

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