AD369 :: Documentação da API

(API de Projetos pela URL: https://api.ad369.com.br/)

Version

Date

Description

0.1

05-Jan-2019

Initial draft

0.2

11-May-2019

Criação desse Docs

1. CDN (Content Delivery Network)

Request

Response

2. get updates

Request

Response

3. deletions

Request

Response

4. get recipe image

Request

Response

Conventions

Status Codes


Webservice

1. CDN (Content Delivery Network)

Utilizado para transporte de conteúdo entre os projetos. Todas as requisições serão autenticadas em midiacriativa.com/cdn

Request

Method

URL            

GET

cdn/package/

GET

cdn/js/

GET

cdn/pure/function/

GET

cdn/pure/class/

Exemplo: http://api.ad369.com.br/cdn/pure/function/moeda irá retornar essa função. Um exemplo de Require inteligente consistira em algo no tipo:

plugin(“moeda”);

E essa função plugin deveria primeiro checar a existência da function naturalmente, e em seguida, procurar pela CDN informada. Caso exista na CDN, então trás, copiando para a pasta funcion natural. O mesmo se aplicaria à class.

Obs: Quando o retorno for em php, no caso de function e class, o retorno será encriptado. Será esperado um token válido para o projeto para concluir a requisição.

Method

URL            

GET

img/src/name/16

GET

img/html/name/16

Retorna uma imagem com o name válido, no tamanho (variável) de 16 pixels. Se chamado por src, trás a URL. Se chamado por html, trás o código <img>  completo.

Type

Params

Values

HEAD

POST

POST

api_key

username

password

string

string

string

api_key

 api_key  must be sent with all client requests. The api_key helps the server to validate the request source.

Response

Status

Response

200

{

    "auth_key": <auth_key>

}

auth_key (string) - all further API calls must have this key in header

403

{"error":"API key is missing."}

400

{"error":"Please provide username."}

400

{"error":"Please provide password."}

401

{"error":"Invalid API key."}

401

{"error":"Incorrect username or password."}

500

{"error":"Something went wrong. Please try again later."}

2. get updates

Get the new updates

Request

Method

URL            

POST

api/updates/

Type

Params

Values

HEAD

POST

auth_key

version

string

number

auth_key

The  auth_key  that was given in response to /api/login

version

The current version of internal recipe database. Each time when updates are pulled from the server through the web service, the internal database version is incremented.

Response

Status

Response

200

Response will be an object containing the list of recipes (array)

as well as the updated recipe database. Each item in the recipe array has the following structure.

{

    "recipe_id": 10,

    "title": "Green Chilly Salad",

    "category": 1,

    "ingredients": {

        "Green Chilly": "1 kg",

        "Salt": "0.5 tbsp"

    },

    "steps": [

        "First clean and cut the chillies",

        "Now you can eat."

    ],

    "remarks": "serves 2 people"

}

An example response is:-

{

    "recipes": [

        {

            "recipe_id": 10,

            "title": "Green Leaf Curry",

            "category": 1,

            "ingredients": {

                "Green leaf": "1 kg",

                "Salt": "0.5 tbsp"

            },

            "steps": [

                "First clean and cut the leaves",

                "Now you can eat."

            ],

            "remarks": "serves 2 people"

        }

    ],

    "version": "4"

}

400

{"error":"Please specify database version."}

400

{"error":"Invalid database version."}

401

{"error":"Invalid API key."}

500

{"error":"Something went wrong. Please try again later."}

3. deletions

Get the recipes that were deleted from the web interface, so that they can be deleted from the internal database also.

Request

Method

URL            

POST

api/deletions/

Type

Params

Values

HEAD

POST

auth_key

version

string

number

version

The current version of internal database. Each time when updates are pulled from the API, the internal database version increases.

Response

Status

Response

200

An array containing the ID’s of recipes to delete is given

Example response:-

{"deletions":[10,11,40], "version":"5"}

400

{"error":"Please specify database version."}

400

{"error":"Invalid database version."}

401

{"error":"Invalid Auth key."}

500

{"error":"Something went wrong. Please try again later."}

4. get recipe image

Get more information on a particular recipe

Request

Method

URL            

GET

api/image/<recipe_id>/

Type

Params

Values

HEAD

URL_PARAM

auth_key

<recipe_id>

string

number

recipe_id

Id of the recipe you want the image of.

Response

Status

Response

200

An array containing the ID’s of recipes to delete is given

Example response:-

{"image":"http:\/\/example.com\/recipe-5-image.jpg"}

400

{"error":"Please provide recipe_id."}

400

{"error":"Invalid recipe_id."}

401

{"error":"Invalid Auth key."}

500

{"error":"Something went wrong. Please try again later."}


Glossary

Conventions

Status Codes

All status codes are standard HTTP status codes. The below ones are used in this API.

2XX - Success of some kind

4XX - Error occurred in client’s part

5XX - Error occurred in server’s part

Status Code

Description

200

OK

201

Created

202

Accepted (Request accepted, and queued for execution)

400

Bad request

401

Authentication failure

403

Forbidden

404

Resource not found

405

Method Not Allowed

409

Conflict

412

Precondition Failed

413

Request Entity Too Large

500

Internal Server Error

501

Not Implemented

503

Service Unavailable

Modelo de DOC extraído de: https://docs.google.com/document/d/1HSQ3Fe77hnthw8hizqvXJU-qGEPHavMkctvCCadkVbY/edit?pli=1#heading=h.jiqojry61jpd