Implement a REST service with Extbase (Typo3) - rest

I'm searching for a way to implement a REST-Service in an extbase extension for Typo3.
I've only found old or not maintained extensions and they doesn't use extbase.
So how could I get an extension that provides an API for external requests?
Something like:
GET www.somedoma.in/service/item/1
I've found this tutorial for Typo3 Flow. So how could I use Flow packages in extbase?
I've also found a way to define own page types like ?type=23123145 where the respond can be manipulated. But i think that's no good idea to implement a REST-Service extension.

I started to create an extension, because I was interested in this topic.
The current state can be found under https://github.com/cundd/rest. It requires cundd_composer to be installed and is a work in process ;-)
Update 1:
Ad: ;-)
the extension is used in production and is under continuing development. To name some of the features:
- Support for Extbase
- Mapping of tables
- Authentication
Update 2:
The project website is live: http://rest.cundd.net

You can't use FLOW3 packages in TYPO3.
AFAIK, TYPO3 hasn't native REST support yet and it can be tricky to use RESTful methods such as PUT or DELETE. However you can with common Extbase ext and RealURL create an API, which will be able to send responses for GET or POST requests.
BTW if the only target of your implementation is to create RESTful API I'd suggest to use some lightweight framework on top of it. Main purpose of the TYPO3 is to deliver universal and comfortable CMS system, but its performance sometimes can not compared to dedicated solutions.

I can recommend the symfony 2 serializer component! I use it as standalone version as lib. Here is a tutorial

Related

Is there any tool to automatically create wiki-like REST API documentation from JSON or Open API?

I have several services, each one exposed through REST API with ASP.NET Core Web API. I use Swashbuckle for ASP.NET Core tooling in order to automatically generate from my controllers and DTOs all the necessary documentation and visualize it in SwaggerUI. I found this tooling really great, with little annotations on my models and my controllers already provides many features out of the box, such as a UI client to try out the REST API endpoints.
But with this solution each service has its own dedicated SwaggerUI instance and therefore UI.
I would like to offer to my customers a wiki-like documentation with a navigation menu, where, for instance, they can browse sections regarding all the endpoints exposed by my services and have on each page the same features offered by SwaggerUI.
It can be achieved by creating my own web application but I was wondering whether an out of the box solution or some tool that might ease such integration already exists.
I tried Slate but I felt like I had to re-invent the wheel in order to automate at least the creation of the basic API documentation, namely controller definition, response definition and descriptions. Does anyone have any suggestion?
I faced this very issue recently working in a microservices architecture, you're absolutely right. There is not need to reinvent the wheel.
I really can't recommend redoc by Redocly enough in this case.
Have a look at the multiple-apis example.

Rest API and admin in the same application

I'm new to building APIs, I made the first one using an MVC framework: codeigniter, with chris kacerguis rest implementation.
I'm not really sure this was the best think to do because I believe maybe the framework is not that "slim" or light just to API's purposes.
I plan to do a mobile App, an admin and a website so the three can consume the Api's services.
Is it a bad idea to have the API, the website and the admin on the same project? which are the pros and cons? or the best architectural approach?
Otherwise I will have: One Codeigniter project for the API and Another Codeigniter project for website and admin
thanks
You can create folders in "controllers" folder to organize your project and use the same project/env configuration :
controllers/Home.php
controllers/api/MyApi.php
controllers/admin/Admin.php
Edit : You will share models and libraries too.
In my project I realized 2 types of controller - REST and API. Admin js gui work with REST, other world work with API. You can do it simply with silex framework, a little brother of symfony.
The purpose of building a REST API so that you only have to build one project for your business model. This allows you to construct any number of applications on any platform, only requiring you to consume the API in different ways. This essentially separates/decouples the user interface from the business logic, and vice versa.
You should create separate projects for the REST API and each UI project should also be separated projects. This allows you to change the underlying code, language and platform in any one of the projects without breaking any of the other projects as long as the API signatures remain the same.
For example, you could have a live version of your website built using Codeignitor while developing another septate project using AngularJS. When your AngularJS project is complete you would simply swap out the project on your server (or create an entirely new website or server) still allowing you to use the other if required. Additionally, you may decide that you would like to move the API onto a different platform, language or database, develope it and swap the implementation when finished causing no changes to any of your UI projects assuming you have not changed the API signatures.

Writing an api-doc for Swagger

I'm trying to use the Swagger UI, and it says that I should begin by writing an api-doc that describes the exact api for a REST api. The problem is that I have no idea what this means. Is this document written in plain English? Or is there a certain format that will be able to generate the UI?
Thank you!
Swagger is a specification for describing REST APIs. Documentation of the specification can be found here - https://github.com/swagger-api/swagger-spec.
Generally, there are two ways to document your API. If you already have an existing API with code, you can use any of the existing libraries (https://github.com/swagger-api/swagger-spec#additional-libraries) to integrate into your code and generate documentation at run time. Some of those libraries also offer offline generation of such docs.
If you're looking to design an API, or would rather not integrate another library into your application, you can use https://github.com/swagger-api/swagger-editor either locally or with the online version - http://editor.swagger.io.
Once you have the documentation, you can use Swagger UI to visualize and test it.

How do you use the Magento API to add products to a bundle?

I'm developing a system that integrates an existing Django application with a Magento store. I've managed, using this library, to create bundle-type products, along with attributes and categories as expected. The problem is that I can't find a way, using the SOAP API (either through the aforementioned library or calling the xmlrpc methods directly), to add products to a previously created bundle. Calling the catalog_product.info method doesn't return anything useful about the bundled objects.
Researching online, I've only found solutions that involve either:
PHP scripts that use the Magento code base
Straight-to-database insertion
Neither of these is currently an option for me right now, and I don't think being able to do this by using just the API (either REST or SOAP) isn't an irrealistic expectation to have.
You can export header information about a bundled product, so I assume you can import it back to Magento. However there does not appear to be a way to import component structure of a bundle. This would be a very complicated interface,

Ember.js & REST API

From all the various examples of Ember.js, I have not been able to figure out if there is a default method in Ember.js to do REST AJAX calls. Many examples build their own interfaces for CRUD operations. I even tried to sift through the code to find any reference to AJAX calls but came up with nothing.
So, my question is, is there a default implementation of REST API in Ember.js. If yes, how do I use it? Also if, for a specific application, I want to build custom CRUD methods, where do I plug these into Ember.js?
It seems that Ember Data is what you are looking for. It is part of emberjs organiztion in GitHub.
[2014-02-18: Deprecated - I no longer support ember-rest because it is overly simplistic, and would recommend using ember-data for most ember projects. Check out the Ember guides for an overview of ember-data as well as this example project ]
While learning Ember, I decided to create a very simple Ember REST library. I also wrote an example Rails CRUD app.
My goals were to keep this project as simple as possible, while still including error handling and validation. Ember REST is certainly much leaner than Ember Data and Ember Resource, and I hope you'll find the code well commented and accessible.
There is a Ember Resource library aiming REST JSON interfaces. It provides Ember.Resource class with save(), fetch() and destroy() operations that could be easily overriden. Looks like it should be more mature than Ember Data for now.
Ember.js can work nicely with Ember Data. That said, there is a specific format of REST to follow. When followed, you can streamline the process of connecting API with Ember and have so much less work.
In case you use custom REST, the place to adjust is:
adapter - to inform from where you like to get data
serializer - how data should be adjusted for custom REST API