Creating a REST API Client and Server

I am interested in creating an application that will provide an API service. Like Facebook, end developers will be able to register the application and receive personalized data to access the provided API through a third-party application. At the moment I want to provide PHP and JavaScript SDKs that will allow developers to access the API through a secure method (private-public keys).

I think I, more or less, understood a common understanding of how to approach this:

  • Built-in REST server that processes requests,
  • Built-in API server, which acts as a barrier between requests and the REST server (checking keys, permissions, etc.).
  • The built-in JavaScript library, equivalent to Facebook "all.js", which is asynchronous to pages and can make API calls dynamically and performs validation on the API server.

In addition, I hope to use the API internally, i.e. make PUT / GET / POST / etc requests through an internal JavaScript file on the site itself.

I hope to use CodeIgniter as a base for launching the application, so if any suggestions on libraries, methods and approaches to this would be fantastic.

In particular, any reference to:

  • SQL table structures for applications, scope queries, role-based permissions, sessions, logs, etc. etc.
  • How to create / templates for the perfect JavaScript library that do the same thing as Facebook "all.js"
  • Libraries that can authorize public and private keys

would be very helpful. I can't seem to find anything.

I know the following:

https://github.com/philsturgeon/codeigniter-restserver

Nonetheless,

which acts as a good template for developing an API, is not authenticated based on the database.

Any help is much appreciated!

+4
source share
3 answers

Drupal8 is built on top of Symfony2 to help with RESTful components in the framework.

So, I would look at this framework.

REST API with Symfony2: the right way

0
source

The best way is to create a regular WEB application with your infrastructure - it is like an admin panel with maximum flexibility, without the need to implement any additional REST calls. And then create the REST API for your application as a module (or plugin) using only the necessary API calls. If you intend to use your REST API for client and internal purposes, one day you will find yourself in your own API.

0
source

The presence of two API levels is usually not required, because for architecture and security reasons, you can divide your code into facade and main logic. As for the client side, I recommend to automatically generate the client based on some autogenerator API descriptor, which will allow you to instantly update the client library. At Kaltura, we generate XML descriptors for ALL API servers that are generated using reflection from the server code, see Example: http://www.kaltura.com/api_v3/api_schema.php From this descriptor, we automatically generate many different client libraries on different coding languages, see Generator: https://github.com/kaltura/clients-generator , you can use it as is.

For more recommendations on the REST API server, see my blog: http://restafar.com/create-new-rest-server/

0
source

Source: https://habr.com/ru/post/1443829/


All Articles