Skip to content

API endpoint

Gus edited this page Feb 2, 2018 · 13 revisions

Here are the following steps to document a new API endpoint:

  1. Create a new folder in content/api with your API name
  2. Create a code_snippets folder inside the previously created api sub-folder to store all your code examples
  3. Create a _index.md file at the root of your API_NAME folder that contains just the following parameter:
---
title: TITLE OF YOUR API
external_redirect: /api/
---
  1. Create an <MY_API>.md file that describes your API:
---
title: TITLE OF YOUR API
type: apicontent
order: XX
---

## TITLE OF YOUR API

This is my API description

Note: The order parameter defines where your API entry is displayed in the main API navigation bar

  1. Create your ENDPOINT.md file that describes your endpoint:
---
title: MY API ENDPOINT
type: apicontent
order: XX.1
---

## ENDPOINT TITLE

This is my endpoint description

##### ARGUMENTS

* `arg_1` [*required*]:  
    My arg_1 description
* `arg_2` [*optional*, *default*=**None**]:  
    My arg_2 description

Note: Increment your order parameter to control the position of your endpoint in your API sub-navigation menu.

  1. Create your code blocks file in the code_snippets folder. There are two types of files:
  • Request code blocks:api-ENDPOINT.py, api-ENDPOINT.rb, and api-ENDPOINT.sh
  • Result code blocks: result.api-ENDPOINT.py, result.api-ENDPOINT.rb, and result.api-ENDPOINT.sh

You need to have a code blocs for all languages currently supported, aka : Python, Ruby, and Curl

  1. Call your ENDPOINT code blocs: create a ENDPOINT_code.md file in your api sub-folder with the following content:
---
title: MY API ENDPOINT
type: apicode
order: XX.1
---

##### Signature

`GET api/v1/my/api/endpoint`

##### Example Request

{{< code-snippets basename="api-ENDPOINT" >}}

##### Example Response

{{< code-snippets basename="result.api-ENDPOINT" >}}

Note: the order parameter must have the same value as the one in your ENDPOINT.md file

Find a complete example of this with the Search API