1. What is API (Application programming interfaces):

An API is a set of programming code that enables data transmission between one software product to another.


In simple terms, an API is a messenger that sends a request to a provider you want data from and then delivers the response back to you.

Example of What API is:

When you use an application on your mobile phone, the application connects to the Internet and sends data to a server. The server then retrieves that data, interprets it, performs the necessary actions and sends it back to your phone. The application then interprets that data and presents you with the information you wanted in a readable way. This is what an API is.




2. Types OF API:

1. Add Api:


(i)Async API


(ii)Sync API:


The only difference between the two APIs is that the sync API does a validation on the server side(on the basis of API Key, Primary Key etc.) before returning the response, while the async API validate only the API key and returns a success response.


(i) Async API call: As the name suggest async api call only validate API key and does not sync the passed attribute parameter with the application (smartech) hence it gives the below success response when API call is made..


URL:


http://api.netcoresmartech.com/apiv2?type=contact&activity=add&apikey=xxx


Body paramter format: {"EMAIL": "mike@google.com", "MOBILE":5654134, "AGE":24, "CITY":"Mumbai" }


Email is the primary key


Response:


{

"requestid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

"result": "Success"

}



(ii) Sync API: Sync API cal does sync all the passed parameter in the API call which is made.


a. Success call:



URL:


http://api.netcoresmartech.com/apiv2?type=contact&activity=addsync&apikey=xxx


Body paramter format: {"EMAIL": "mike@google.com", "MOBILE":5654134, "AGE":24, "CITY":"Mumbai" }


Email is the primary key


Response:


{

"requestid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

"result": "Success"


"details"


Data added successfully

}




b. Unsuccessful/Error highlighted by sync API call:


Use case: Email id already present in the panel and re-added using the addsync call.



URL:


http://api.netcoresmartech.com/apiv2?type=contact&activity=addsync&apikey=xxx


Body Paramter format:


{"EMAIL": "mike@google.com", "MOBILE":5654134, "AGE":24, "CITY":"Mumbai" }


Email is the primary key



Error Response:


{

"status": "error",

"error_code": 302,

"details": "Duplicate entry 'xxxxxxxxxxxxxxxxxxxxx' for key 'uniqid'"

}




2. Update API:



This API can be used to update the attribute details of a user in Smartech and its async in nature.


URL:


http://api.netcoresmartech.com/apiv2?type=contact&activity=update&apikey=xxxxxxx


Body Paramter format:



{"EMAIL": "mike@google.com", "MOBILE":5654134124, "AGE":22, "CITY":"Delhi" }


Email is the primary key



Response message:


{

"requestid": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

"result": "Success"

}