#105

Product support

Visit this product's website for support.

Categories

  • Developer Tools
  • Miscellaneous
  • Security
  • Utility

Awebsome provide you a Simple API

With this plugin you can extend and connect your project with: other projects, applications and CRM like Salesforce, simply creating a Token and the Resources you want.

Features

  • Tokens
    • Basic Authorization
    • Unlimited tokens for multi utilities
    • Assignment of global permissions
    • Assignment of permissions only specific resources
  • Resources
    • Unlimited resources
    • Assignment of permissions

Methods & Functions

  • GET
    • Get record by Id
    • List all the records of a resource
    • Get record by column
    • Get records by query
    • Get limit records
    • Get a range of records
    • Obtain records ordered by "x" column
  • POST
    • Create record
    • Update a record by POST
  • PUT
    • Update a record by Id
    • Update many records by query
  • DELETE
    • Delete one or more records

Methods ( API Version 1.0 )

Authentication

The Simple API supports authentication through Basic Auth. You must provide your client_id and API key from your tokens. All requests require authentication.

  • GET
    • Get record by Id
    • List all the records of a resource
    • Get record by column
    • Get records by query
    • Get limit records
    • Get a range of records
    • Obtain records ordered by "x" column
  • POST
    • Create record
    • Update a record by POST
  • PUT
    • Update a record by Id
    • Update many records by query
  • DELETE
    • Delete one or more records

URL parameters:

  • Required (*)
  • Optional (?)

GET:

GET: https://domain.com/api/:version/:resource/:query?/:pagination?

@var :version       string  *    # Api Version
@var :resource      string  *    # Resource (Model/Entity)
@var :query         string  ?    # Parameters of the query (wheres)
@var :pagination    string  ?    # Parameters of page

=======================================================================

/**
* @var :query 
* ===============================================
* Receive 1 to 3 parameters per query delimited with ":"
* 1 (one) parameter in a single query assumes a record @id
* 2 (two) parameters in the query assume: @column and @value
* 3 (three) parameters in the query assume: @column, @operator and @value
*  Delimitation of multi-queries delimited by ";"
*/

var         Parameters:                 Details:
:query      @id                         # Record ID
:query      @column:@value              # email:[email protected]
:query      @column:@operator:@value    # votes:>=:100

/*
* Combined query example:
* votes:>=:100;votes:<=:200;status:Active;category:5;
* This should go in the url in the :query position
*/

=======================================================================

/**
* @var :pagination 
* ===============================================
* Receive 1 to 2 parameters between "[]" delimited by "space".
* [@pagination @order]
* ------------------------------------------------------------
* @pagination receive 1 to 2 integers delimited by "-"
* - [int] assumes a records limit.
* - [int-int] assumes a records pagination [start-end]
* - [*] assumes all records
* ------------------------------------------------------------
* @order receive two strings delimited by ":"
* - column_name and order (asc o desc)
* - [* @column:@order]
*/

var             Parameters:         Details:
:pagination     [@limit]                # Limit records
:pagination     [@[email protected]]           # Page range of start and end
:pagination     [* @column:@order]      # All records order by column asc/desc

/*
* Examples of pagination of records:
* ===============================================
* [100] returns 100 records.
* [100-200] returns from record 100 to 200.
* [* id:desc] returns all sorted by (id desc).
* [100 created_at:desc] returns 100 records, order by created_at desc
* [10-20 votes:desc] returns from record 10 to 20 order by votes desc
* This should go in the url in the :pagination position
*/

POST:

POST: https://domain.com/api/:version/:resource/:id

@var :version     string      *    # API Version
@var :resource    string      *    # Resource (Model/Entity)
@var :id          int/string  ?    # Record ID (to update)

PUT:

PUT: https://domain.com/api/:version/:resource

@var :version       string  *    # API Version
@var :resource      string  *    # Resource (Model/Entity)

DELETE:

DELETE: https://domain.com/api/:version/:resource

@var :version       string      *    # API Version
@var :resource      string      *    # Resource (Model/Entity)

Resources & Methods:

Create a record.

Post with the fields and values to insert.

Request:
POST: https://domain.com/api/v1/Contacts
-H "Content-Type: application/json"

{
    "salesforce_id": "00D0S00fn00Co28",
    "name": "Nombre",
    "lastname": "Apellido",
    "phone1": "1235554344"
}
Response:
{
    "version": "v1",
    "resource": "Contacts",
    "action": "create",
    "method": "POST",
    "request": {
        "salesforce_id": "00D0S00fn00Co28",
        "name": "Nombre",
        "lastname": "Apellido",
        "phone1": "1235554344"
    },
    "data": {
        "salesforce_id": "00D0S00fn00Co28",
        "name": "Nombre",
        "lastname": "Apellido",
        "phone1": "1235554344",
        "updated_at": "2017-06-01 18:39:12",
        "created_at": "2017-06-01 18:39:12",
        "id": "4"
    }
}

Update records with PUT.

To update a record, by default it is assumed that the resource has a column called "id" which must be included in the request. To update one or more records by a different column, it must be done by :query from the URL.

Request:
PUT: https://domain.com/api/v1/Contacts
-H "Content-Type: application/json"

{
    "id": "4",
    "name": "Nuevo Nombre",
    "phone1": "1235554344"
}
Response:
{
    "version": "v1",
    "resource": "Contacts",
    "action": "update",
    "method": "PUT",
    "request": {
        "id": "4",
        "name": "Nuevo nombre",
        "phone1": "1235554344"
    },
    "data": {
        "id": 4,
        "salesforce_id": "00D0S00fn00Co22",
        "name": "Nuevo nombre",
        "lastname": "Apellido",
        "phone1": "1235554344",
        "phone2": "",
        "created_at": "2017-07-25 18:10:07",
        "updated_at": "2017-09-20 15:43:16",
        ...,
        ...
    }
}

Update a record with POST.

If the function is enabled in the configuration of the resource, a simple update of the record can be performed by POST including the ID of the record in the request or URL.

Request:
POST: https://domain.com/api/v1/Contacts/4
-H "Content-Type: application/json"

{
    "name": "Nuevo nombre",
    "phone1": "1235554344"
}
Response:
{
    "version": "v1",
    "resource": "Contacts",
    "action": "update",
    "method": "POST",
    "request": {
        "name": "Nuevo nombre",
        "phone1": "1235554344"
    },
    "data": {
        "id": 4,
        "salesforce_id": "00D0S00fn00Co22",
        "name": "Nuevo nombre",
        "lastname": "Apellido",
        "phone1": "1235554344",
        "phone2": "",
        "created_at": "2017-07-25 18:10:07",
        "updated_at": "2017-09-20 15:43:16",
        ...,
        ...
    }
}

Get records

To obtain records, send the parameters by the Url.


Get record by ID

Request:
GET: https://domain.com/api/v1/Contacts/2
# Retruns a record by ID
Response:
{
    "version": "v1",
    "resource": "Contacts",
    "action": "show",
    "method": "GET",
    "query": {
        "type": "find",
        "query": "2",
        "pagination": null
    },
    "request": [],
    "data": {
        "id": 2,
        "salesforce_id": "...",
        "name": "...",
        "lastname": "...",
    }
}

Get list of records

Requests:

Get a record by Id:

GET: https://domain.com/api/v1/Contacts/@id
# Returns a record by ID.

List all records:

GET: https://domain.com/api/v1/Contacts
# Returns a list of all resource records.

Get records by Column:

GET: https://domain.com/api/v1/Contacts/salesforce_id:xxxidxxx
# Returns a list of all records by @column:@value

Get records by query:

GET: https://domain.com/api/v1/Contacts/id:>=:1;id:<=:100;status:active
# Returns a list whose query is equivalent to:
# id >= 1 & id <= 100 & status == active

Get limited records:

GET: https://domain.com/api/v1/Contacts/id:>=:1/[100]
# Returns a list with limit 100

Get paginated records:

GET: https://domain.com/api/v1/Contacts/id:>=:1/[100-200]
# Returns a paginated list from record 100 to 200.

Get some paginated records and ordered by column

GET: https://domain.com/api/v1/Contacts/status:active/[100-200 date:desc]
# Returns a paginated list from 100 to 200 ordered by date desc.

Get all paginated records and ordered by column:

GET: https://domain.com/api/v1/Contactos/status:active/[* date:desc]
# Returns all records list ordered by date desc.
Response:
{
    "version": "v1",
    "resource": "Contacts",
    "action": "show",
    "method": "GET",
    "query": {
            "type": "...",
            "query": [ ... ],
            "pagination": { ... }
        }
    },
    "request": [],
    "data": {
        "0": {... },
        "1": {... },
        "2": {... }
    }
}

Delete records

To delete one or more records you must send the column and value in the request.

Request:
# Delete record

DELETE: https://domain.com/api/v1/Contacts
-H "Content-Type: application/json"

{
    "salesforce_id": "00D0S00fn00Co22"
}

=================================================

# Delete many records 

DELETE: https://domain.com/api/v1/Contacts
-H "Content-Type: application/json"

{
    "status": "ReadyToDelete"
}
Response:
{
    "version": "v1",
    "resource": "Contacts",
    "action": "delete",
    "method": "DELETE",
    "request": {
        "status": "ReadyToDelete"
    },
    "data": {
        "success": "5 Deleted records",
        "records": 5,
        "error": ""
    },
}
1.0.4

Update Tokens Permissions

Mar 31, 2018

1.0.3

Update Resources Table

Mar 31, 2018

1.0.2

Create Tables

Mar 31, 2018

1.0.1

Initialize plugin.

Mar 31, 2018