Composer in API-ji

Tit Petrič, Monotek d.o.o.

Composer in API-ji

Tit Petrič (@TitPetric)

Photo © Jeffrey Bass @ Flickr

Kdo sem

Composer

Zakaj composer?

* tako npm kot rubygems sta daleč naprej po nastanku in uporabi

Implementacija composer paketov

API-ji

Na kaj paziti pri APIjih?

Vzor in inspiracija

JSON Schema, describes your JSON data format.

JSON Schema - json-schema.org

Swagger is a simple yet powerful representation of your RESTful API.

Swagger - http://swagger.io

Collaborative design, instant API mock, generated documentation, integrated code samples, debugging and automated testing.

Apiary - http://apiary.io

Vzor in inspiracija

There isn't anything we enjoy more than seeing talented designers and engineers using Tumblr to invent whole new forms of creative expression.

Tumblr - https://www.tumblr.com/docs/en/api/v2

OVH API is a Web service allowing OVH customers to buy, manage, upgrade and configure OVH products without using the graphical customer interface (OVH manager).

OVH - https://api.ovh.com/console/

Composer paket
kot API

API Shema

{
	"interface": "News",
	"title": "News API",
	"protocol": "http",
	"type": "private",
	"path": "/news",
	"auth": ["client"],
	"errors": {
		"E_HTTPS": "Call must to be delivered over HTTPS."
	},
	"apis": {
		"getLayouts": {
			"method": "GET",
			"icon": "check",
			"path": "/news/getLayouts",
			"title": "Get layout names"
		}, ...

Composer paket kot API: v praksi

Composer paket kot API

Composer paket kot API

Dodajanje parametrov

		$api = new MMC\API\Providers\News;
		$api->getSearch($q, $prepare, $pageNumber, $pageSize);
		
		$api = new MMC\API\Providers\News;
		$api->getSearch($q, $section, $prepare, $pageNumber, $pageSize);
		

Trajno delovanje

		$api = new MMC\API\Endpoints\News;
		$api->post("getSearch", compact("q", "prepare", "language"));
		

Vas zanimajo RTVSLO API-ji?

Pošljite naslednje podatke na mmc@rtvslo.si

Lahko pa predlagate tudi kak nov API, ki bi ga radi imeli

Vprašanja?