Implementing your API Rest

In this chapter, we will not cover all aspects of server-side coding, but simply summarize some basic technical elements that you should take care of.

There are several languages / Frameworks available to develop a server-side API (php, asp, node.js…), but we will focus on a simple example with php-mysql.

Php-MySQL API Example

Let’s say you want to create an API that will return the data from a MYSQL Table with customers information and allow a search on the customer country:

  • Step 1 The first thing to do is to get the parameters sent to the API, in our example, we will just add a filter for the customer country: 

    ...
  • Step2 Connect to the Database and execute the SQL

    ...
  • Step3 Loop on the results and populate an Array, and convert the result Array to JSON

    ...
  • Step4 Set the header for the result and return the JSON

    ...
Copyright©  Nymphide Lab 2020 - All Rights Reserved 

...