Learn how we can create PHP Rest API.

REST API means Representational state transfer is a software architectural style that defines a set of constraints to be used for creating Web services. In this article, you’ll learn everything you need to know about REST APIs to be able to read the API documentation and use them in your project.

What is REST Api

What is the REST API?

Let say if you want to find a person on twitter you go to twitter search bar enter person name and hit enter you find no of user matching your search term. REST API works in a similar way, you search for something you get a list of results back from the server.

What is API?

API is an application programming interface, It Is basically a set of rules that define how the software will communicate. The developer creates API in a server and allows the client to communicate with the server.

REST determines how the API looks like. It stands for “Representational State Transfer”. It is a set of rules that developers follow when they create their API.  It is an architectural style for distributed hypermedia systems and was first presented by Roy Fielding in 2000 in his famous dissertation.

In REST API Each URL is called a request while the data sent back to you is called a response.

Anatomy Of A REST API Request

  1. The endpoint
  2. The method
  3. The headers
  4. The data (or body)

Sample JSON Response from REST API

  "created_at": "Thu Apr 06 15:24:15 +0000 2017",
  "id_str": "850006245121695744",
  "text": "1\/ Today we\u2019re sharing our vision for the future of the Twitter API platform!\nhttps:\/\/t.co\/XweGngmxlP",
  "user": {
    "id": 2244994945,
    "name": "Twitter Dev",
    "screen_name": "TwitterDev",
    "location": "Internet",
    "url": "https:\/\/dev.twitter.com\/",
    "description": "Your official source for Twitter Platform news, updates & events. Need technical help? Visit https:\/\/twittercommunity.com\/ \u2328\ufe0f #TapIntoTwitter"
  "place": {   
  "entities": {
    "hashtags": [      
    "urls": [
        "url": "https:\/\/t.co\/XweGngmxlP",
        "unwound": {
          "url": "https:\/\/cards.twitter.com\/cards\/18ce53wgo4h\/3xo1c",
          "title": "Building the Future of the Twitter API Platform"
    "user_mentions": [     


To learn how we can create PHP Rest API you can read this post.