A single App definition
This is an example of how the Flickr
integration is set up in haxtheweb.org. Below this integration's pieces have been annotated i order to illustrate what each provides to HAX. For more advanced integrations see the complete example
.
{
// info about the source of this integration
"details": {
// title to display in the UI
"title": "Flickr",
// icon to represent it in UIs
"icon": "image:collections",
// an optional image to present it
"image": "flickr.jpg",
// color to accent it in UIs
"color": "pink",
// author of the app (future)
"author": "Yahoo",
// description (future)
"description": "The original photo sharing platform on the web.",
// status (future)
"status": "available",
// rating (future)
"rating": "0",
// tags for grouping sources (future)
"tags": ["images", "creative commons", "crowdsourced"]
},
// the connection object declares how to connect to this service
"connection": {
"protocol": "https",
"url": "api.flickr.com",
// any additional headers that need added
"headers": {
"Authorization": "Bearer POTENTIALLYSOMEBIGSIGNATUREHERE"
},
// any data to send with the API call, usually for authorization or querying
"data": {
"api_key": "SOMEBIGKEYHERE"
},
// supported operations include, browse, read, edit, add, delete
"operations": {
"browse": {
"method": "GET",
"endPoint": "services/rest",
// pagination methodology (future)
"pagination": {
"style": "page",
"props": {
"per_page": "photos.perpage",
"total_pages": "photos.pages",
"page": "photos.page"
}
},
// data needed in order to search this
"search": {
// JSON schema of key to search with, label to supply and input field type
"text": {
"title": "Search",
"type": "textfield"
},
"license": {
"title": "License type",
"type": "select",
"options": {
"1": "Public domain",
"2": "CC attribution",
"3": "CC Zero",
"4": "CC Share-alike"
}
}
},
// data to send on requests
"data": {
"method": "flickr.photos.search",
"text": "",
"safe_search": "1",
"per_page": "20",
"page": "1",
"format": "json",
"nojsoncallback": "1",
"extras": "license,description,url_l,url_s"
},
// a map of the information coming across the wire
"resultMap": {
// what type of gizmo to match results to
"defaultGizmoType": "video",
// the location where the items are found in the response
"items": "resource.items.collection",
// what data to map to in a preview
"preview": {
"title": "Stuff",
"details": "Details",
"image": "whatever.jpg",
"id": "meta.id"
},
// the fields and what they map to off the API
"gizmo": {
"type": "",
"title": "",
"description": "",
"source": "",
"citation": "",
"alt": "",
"caption": "",
"color": ""
}
}
},
// reading individual nodes off the API
"read": {
"method": "GET",
"endPoint": "node/<%= id %>",
"data": {
"deep-load-refs": "node"
}
},
// editing inputs (future)
"edit": {
"method": "PUT",
"endPoint": "node/<%= id %>/update"
},
// adding / uploading connection details
"add": {
"method": "POST",
"endPoint": "node",
"data": {
"title": "A new item",
"img": "This is the image"
}
},
// delete request details
"delete": {
"method": "DELETE",
"endPoint": "node/<%= id %>/delete"
}
}
}