Documentation

How to Use API

Lorem ipsum be be bleh.

HTTP Verbs

HTTP Verb Description
GET Used for retrieving records
PATCH Used for updating records
POST Used for creating records
PUT Used for updating records implemented as patch
DELETE Used for deleting records

Status Codes

Used Status Codes

Status Code Description Usage
2xx - Success 200 OK General success code
  201 Created Success code for creating records
  204 No Content Success without response
3xx - Redirection 304 Not Modified
4xx - Client Error 400 Bad Request
  401 Unauthorized
  403 Forbidden
  404 Not Found
  405 Method Not Allowed
  409 Conflict
5xx - Server Error 500 Internal Server Error
  501 Not Implemented
  502 Bad Gateway
  503 Service Unavailable

Summary

2xx - Success 3xx - Redirection 4xx - Client Error 5xx - Server Error
200 - OK 304 - Not Modified 400 - Bad Request 500 - Internal Server Error
201 - Created   401 - Unauthorized 501 - Not Implemented
204 - No Content   403 - Forbidden 502 - Bad Gateway
    404 - Not Found 503 - Service Unavailable
    405 - Method Not Allowed  
    409 - Conflict  

Parts of a Request

parts of request
Name Description
Protocol Http or Https
Domain Name or Base URL The server in which the API resides
API Version Current version of the API
Resource Refers to the resource to be retrieved or modified
Parameters URL query string

Conventions

At the moment the API supports camel, pascal, underscore, snake and dash cases. That being said, developers should refrain from using other cases like UPPERCASE for example.

The API is case sensitive when it comes to its URI but case insensitive else where.

http://api.mymovementrx.com/v1/companies is not equal to http://api.mymovementrx.com/v1/Companies

but

http://api.mymovementrx.com/v1/companies?api-key=s3cur3k3y is equal to http://api.mymovementrx.com/v1/companies?ApiKey=s3cur3k3y

URI Conventions

URI follow the convention of using dash case and the plural form of the resource.

http://api.mymovementrx.com/v1/therapists/1/therapist-educations

Notice that both therapists and therapist-educations are in plural form and therapist-educations uses the dash case.


Parameter Conventions

Request parameters should accept any of the given cases.

http://api.mymovementrx.com/v1/therapists?api-key=s3cur3k3y is equal to http://api.mymovementrx.com/v1/therapists?apiKey=s3cur3k3y

Notice that api-key on the first url is in dash case while apiKey on the other url is in camel case.


POST Value Conventions

The API is case insensitive with its post values and should accept any of the given cases.

[
    'name' => 'Prosoft',
    'group_id' => 'Prosoft',
    'phone' => '443-78-20',
    'contact_person_email' => 'rommel.berganio@prosoft-phils.com',
    'contact_person_last_name' => 'Berganio',
    'contact_person_first_name' => 'Rommel',
    'contact_person_middle_initial' => 'G',
    'status_id' => 1,
    'date_created' => date('Y-m-d H:i:s'),
    'date_updated' => date('Y-m-d H:i:s'),
    'is_archived' => 0
]
                

is equal to

[
    'Name' => 'Prosoft',
    'GroupId' => 'Prosoft',
    'Phone' => '443-78-20',
    'ContactPersonEmail' => 'rommel.berganio@prosoft-phils.com',
    'ContactPersonLastName' => 'Berganio',
    'ContactPersonFirstName' => 'Rommel',
    'ContactPersonMiddleInitial' => 'G',
    'StatusId' => 1,
    'DateCreated' => date('Y-m-d H:i:s'),
    'DateUpdated' => date('Y-m-d H:i:s'),
    'IsArchived' => 0
]
                

Notice that the first array keys are in underscore/snake case while the other array's keys are in pascal case.


Request Parameters

Used Request Parameters

api-key

Without the API key any response to the server will be rejected.
Can be added as http header.

http://api.mymovementrx.com/v1/companies?api-key=s3cur3k3y

limit

Limits the number or response

http://api.mymovementrx.com/v1/companies?limit=100

offset

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies?offset=100

order

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies?order=desc

sort

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies?sort=name&order=desc

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies?sort=name,description&=desc,asc

format

Lorem Ipsum Dolor

json,jsonp,xml,serialized,csv

http://api.mymovementrx.com/v1/companies?format=json

case

Lorem Ipsum Dolor

camel,pascal,underscore,snake,dash

http://api.mymovementrx.com/v1/companies?case=camel

envelope

Lorem Ipsum Dolor

true or false

http://api.mymovementrx.com/v1/companies?envelope=false

fields

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies?fields=name,description,date_created

search-term

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies/search?search-term=Prosoft

search-fields

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies/search?search-term=Prosoft&search-fields=name,descriptions

callback

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies?format=jsonp&callback=jsonCallback

delimiter

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies?format=csv&delimiter=|

Summary

Name Description Sample Usage
api-key
limit
offset
order
sort
format
case
envelope
fields
search-term
search-fields
callback
delimeter

Retrieving Data

You can retrieve data using the HTTP Verb GET be be bleh.

All Records

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies

Specific Record

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies/1

Filtered Records

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies?status=active

Child Records

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies/1/providers

Specific Child Record

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies/1/providers/1

Filtered Child Records

Lorem Ipsum Dolor

http://api.mymovementrx.com/v1/companies/1/providers?status=inactive

Searching Data

You can search data using the HTTP Verbs GET or POST.

Search using GET

Lorem Ipsum Dolor

GET: http://api.mymovementrx.com/v1/companies/search/Prosoft
GET: http://api.mymovementrx.com/v1/companies/search?search-term=Prosoft

Search using POST

Lorem Ipsum Dolor

POST: http://api.mymovementrx.com/v1/companies/search
[
    'search-term' => 'Prosoft'
]

Choosing Search Fields

Lorem Ipsum Dolor

GET|POST: http://api.mymovementrx.com/v1/companies/search?search-term=Prosoft&search-fields=name,description

Creating Data

You can create a record using the HTTP Verb POST be be bleh.

Single Record

Lorem Ipsum Dolor

POST: http://api.mymovementrx.com/v1/companies

See the format below

[
    'name' => 'Prosoft',
    'group_id' => 'Prosoft',
    'phone' => '443-78-20',
    'contact_person_email' => 'rommel.berganio@prosoft-phils.com',
    'contact_person_last_name' => 'Berganio',
    'contact_person_first_name' => 'Rommel',
    'contact_person_middle_initial' => 'G',
    'status_id' => 1,
    'date_created' => date('Y-m-d H:i:s'),
    'date_updated' => date('Y-m-d H:i:s'),
    'is_archived' => 0
]

Multiple Records

Lorem Ipsum Dolor

POST: http://api.mymovementrx.com/v1/companies/add

See the format below

[ 
    'records' => [
        0 => [
            'name' => 'Prosoft',
            'phone' => '443-78-20',
            'contact_person_email' => 'rommel.berganio@prosoft-phils.com',
            'contact_person_last_name' => 'Berganio',
            'contact_person_first_name' => 'Rommel',
            'contact_person_middle_initial' => 'B',
            'status_id' => 1,
            'date_created' => date('Y-m-d H:i:s'),
            'date_updated' => date('Y-m-d H:i:s'),
            'is_archived' => 0
        ],
        1 => [
            'name' => 'Another Company',
            'phone' => '443-78-20',
            'contact_person_email' => 'another@prosoft-phils.com',
            'contact_person_last_name' => 'Another First',
            'contact_person_first_name' => 'Another Last',
            'contact_person_middle_initial' => 'B',
            'status_id' => 1,
            'date_created' => date('Y-m-d H:i:s'),
            'date_updated' => date('Y-m-d H:i:s'),
            'is_archived' => 0
        ]
    ]
]

Single Child Record

Company will automatically be related to provider

POST: http://api.mymovementrx.com/v1/providers/1/companies

See the format below

[
    'name' => 'Prosoft',
    'group_id' => 'Prosoft',
    'phone' => '443-78-20',
    'contact_person_email' => 'rommel.berganio@prosoft-phils.com',
    'contact_person_last_name' => 'Berganio',
    'contact_person_first_name' => 'Rommel',
    'contact_person_middle_initial' => 'G',
    'status_id' => 1,
    'date_created' => date('Y-m-d H:i:s'),
    'date_updated' => date('Y-m-d H:i:s'),
    'is_archived' => 0
]

Multiple Child Records

Companies will automatically be related to provider

POST: http://api.mymovementrx.com/v1/providers/1/companies/add

See the format below

[ 
    'records' => [
        0 => [
            'name' => 'Prosoft',
            'phone' => '443-78-20',
            'contact_person_email' => 'rommel.berganio@prosoft-phils.com',
            'contact_person_last_name' => 'Berganio',
            'contact_person_first_name' => 'Rommel',
            'contact_person_middle_initial' => 'B',
            'status_id' => 1,
            'date_created' => date('Y-m-d H:i:s'),
            'date_updated' => date('Y-m-d H:i:s'),
            'is_archived' => 0
        ],
        1 => [
            'name' => 'Another Company',
            'phone' => '443-78-20',
            'contact_person_email' => 'another@prosoft-phils.com',
            'contact_person_last_name' => 'Another First',
            'contact_person_first_name' => 'Another Last',
            'contact_person_middle_initial' => 'B',
            'status_id' => 1,
            'date_created' => date('Y-m-d H:i:s'),
            'date_updated' => date('Y-m-d H:i:s'),
            'is_archived' => 0
        ]
    ]
]

Updating Data

You can update a record using the HTTP Verbs PUT or PATCH be be bleh.

Simple Update

Lorem Ipsum Dolor

PATCH|PUT: http://api.mymovementrx.com/v1/companies

See the format below

[
    'name' => 'Prosoft',
    'group_id' => 'Prosoft',
    'phone' => '443-78-20',
    'contact_person_email' => 'rommel.berganio@prosoft-phils.com',
    'contact_person_last_name' => 'Berganio',
    'contact_person_first_name' => 'Rommel',
    'contact_person_middle_initial' => 'G',
    'status_id' => 1,
    'date_created' => date('Y-m-d H:i:s'),
    'date_updated' => date('Y-m-d H:i:s'),
    'is_archived' => 0
]

Update Child

This will make sure that the record being updated belongs to a parent before updating it.

PATCH|PUT: http://api.mymovementrx.com/v1/provider/1/companies

See the format below

[
    'name' => 'Prosoft',
    'group_id' => 'Prosoft',
    'phone' => '443-78-20',
    'contact_person_email' => 'rommel.berganio@prosoft-phils.com',
    'contact_person_last_name' => 'Berganio',
    'contact_person_first_name' => 'Rommel',
    'contact_person_middle_initial' => 'G',
    'status_id' => 1,
    'date_created' => date('Y-m-d H:i:s'),
    'date_updated' => date('Y-m-d H:i:s'),
    'is_archived' => 0
]

Deleting Data

You can delete data using the HTTP Verbs DELETE or POST respectively.

Single Delete

Lorem Ipsum Dolor

DELETE: http://api.mymovementrx.com/v1/companies/1

Multiple Delete

Lorem Ipsum Dolor POST

POST: http://api.mymovementrx.com/v1/companies/delete
[
    'records' => [1,2,3]
]

Single Delete Child

This will make sure that the child belongs to a parent before deleting it.

DELETE: http://api.mymovementrx.com/v1/providers/1/companies/1

Multiple Delete Children

This will make sure that the records belongs to a parent before deleting them.

POST: http://api.mymovementrx.com/v1/providers/1/companies/delete
[
    'records' => [1,2,3]
]

Attaching Records

You can attach records using the HTTP Verbs PATCH, POST or PUT.

Attaching refers to relating a record to another record or records

Single Attach

Lorem Ipsum Dolor

PATCH|PUT|POST: http://api.mymovementrx.com/v1/providers/1/companies/1/attach

Single Attach with Pivot

If the relation is many to many you may add pivot values to the relational table.

PATCH|PUT|POST: http://api.mymovementrx.com/v1/providers/1/companies/1/attach
[
    'pivot' => [
        'description' => 'Some Description',
        'date_updated' => 'Some date'
    ]
]

Multiple Attach

Lorem Ipsum Dolor POST

POST: http://api.mymovementrx.com/v1/providers/1/companies/attach
[
    'records' => [1,2,3]
]

Multiple Attach with Pivot

Lorem Ipsum Dolor POST

POST: http://api.mymovementrx.com/v1/providers/1/companies/attach
[
    'records' => [
        1 => [
            'description' => 'Some description'
        ],
        2 => [
            'description' => 'Some other description'
        ],
        3 => [
            'description' => 'Last description'
        ]
    ]
]

Detaching Records

You can detach records using the HTTP Verbs PATCH, POST or PUT.

Detaching refers to the removal of a record's relation to another record or records

Single Detach

Lorem Ipsum Dolor

PATCH|PUT|POST: http://api.mymovementrx.com/v1/providers/1/companies/1/detach

Multiple Detach

Lorem Ipsum Dolor POST

POST: http://api.mymovementrx.com/v1/providers/1/companies/detach
[
    'records' => [1,2,3]
]


Syncing Records

You can sync records using the HTTP Verbs PATCH, POST or PUT.

Sync is similar to attach except it deletes all existing relations that are not part of the sync

Single Sync

Lorem Ipsum Dolor

PATCH|PUT|POST: http://api.mymovementrx.com/v1/providers/1/companies/1/sync

Single Sync with Pivot

If the relation is many to many you may add pivot values to the relational table.

PATCH|PUT|POST: http://api.mymovementrx.com/v1/providers/1/companies/1/sync
[
    'pivot' => [
        'description' => 'Some Description',
        'date_updated' => 'Some date'
    ]
]

Multiple Sync

Lorem Ipsum Dolor POST

POST: http://api.mymovementrx.com/v1/providers/1/companies/sync
[
    'records' => [1,2,3]
]

Multiple Sync with Pivot

Lorem Ipsum Dolor POST

POST: http://api.mymovementrx.com/v1/providers/1/companies/sync
[
    'records' => [
        1 => [
            'description' => 'Some description'
        ],
        2,
        3
    ]
]