0

I have been using Phalcon to develop my web system, and have added to it an API where orders can be sent through and stock numbers can be requested.

I am new to web services, so just wandering, is my API a RESTful API?

  • All requests go through http://myurl.com/api.
  • All requests have to put an "API-Key" in the header of the request which is used to authenticate.
  • If they want to download the stock numbers, they send a "GET" to http://myurl.com/api/stock
  • If they want to send an order through, then send a "POST" to http://myurl.com/api/order with a "data" parameter which contains a json_encoded array of the order details.

Returned data is usually a 200 status code with either success or fail (except invalid API keys which return a 401).

Lock
  • 5,094
  • 12
  • 58
  • 98
  • the term is used pretty loosely but there are specs for it... http://www.w3.org/2001/sw/wiki/REST && http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html && http://en.wikipedia.org/wiki/Representational_state_transfer – pherris Feb 14 '15 at 00:15
  • [Here](http://www.restapitutorial.com/lessons/whatisrest.html) are the six requirements for a service to be RESTful. These requirements were originally laid out by Roy Fielding in his doctoral thesis. Can you check your service against each one and answer your own question? – Tim Biegeleisen Feb 14 '15 at 00:35

2 Answers2

1

You can answer this question yourself. Maybe your API is a RESTful API.
But before that you need to know somethings...

  1. What is RESTful Services/Programming..?
    I've got a nice and to-the-point Answer for the same

    Some points summarized here...
    • URIs are the ubiquitous choice of identifier these days. Let URI be identifying every resource and services you wanna expose.
    • HTTP methods are used. Create, Retrieve, Update & Delete are handled by HTTP POST, GET, PUT & DELETE methods respectively.
    • Return the result with following appropriate HTTP Response Codes

HTTP Code Chart against type of HTTP Request

  1. Does your API Offer Both JSON and XML

    Favor JSON support unless you're in a highly-standardized and regulated industry that requires XML, Schema validation and namespaces. And offer both JSON and XML unless the costs are staggering. Ideally, let consumers switch between using the HTTP Accept header, or by just changing an extension from .xml to .json on the URL.

    Be warned though, as soon as we start talking about XML support, we start talking about schemas for validation, namespaces, etc. Unless required by your industry, avoid supporting all that complexity initially, if ever. JSON is designed to be simple, terse and functional. Create your XML to look like that if you can.

    In other words, make the XML that is returned more JSON-like: simple and easy to read, without the schema and namespace details present—just data and links. If it ends up being more complex than this, the cost of XML will be staggering. In my experience nobody uses the XML responses anyway over the last several years. It's just too expensive to consume.

    To read more on How a RESTful API should be

  2. Please read the valuable comments of this answer as well. It'll really help. (Also you can read the answer for if you want some more details)


Now, I think you can decide for yourself whether your API is a RESTful API

Community
  • 1
  • 1
Benison Sam
  • 2,547
  • 4
  • 22
  • 34
1

Does your service meet with the HTTP and URI standards? Does it serve a standard hypermedia format? Do your clients follow the hyperlinks given by the service, instead of building the followed URIs and methods on their own? Are the hyperlinks and the response data annotated with metadata, which can be used by the clients to understand what the response mean and how to process it? Do your client send the information necessary to identify the client with every request? Would these requests work after a complete server restart?

inf3rno
  • 20,735
  • 9
  • 97
  • 171