Rest API draft

Accept Types

The implementation of the API will eventually allow easy addition of other file formats other than JSON, such as XML, by use of the "Accept-Types" HTTP header.

Endpoints

Name Method URL Description Sample Response
Info Get GET /api/info/<int:modelid> Returns the model information for modelid as JSON. JSON:(a)
Model Get GET /api/model/<int:modelid> Returns a zip with the model of the specified modelid. zip file
Tag Lookup GET /api/tag/<string:tag>/<int:pageid> Returns model ids as JSON that have tag as one of their tags. pageid is optional, specifies the page. JSON:[3,5]
Category Lookup GET /api/category/<string:category>/<int:pageid> Returns model ids as JSON that have category as one of their categories. pageid is optional, specifies the page. JSON:[6,8]
Author Lookup GET /api/author/<string:author>/<int:pageid> Returns model ids as JSON that have author as their author. pageid is optional, specifies the page. JSON:[3,20,432]
Latitude and Longitude Search GET /api/search/<float:lat>/<float:lon>/<float:range>/<int:pageid> Returns model ids as JSON within range meters of a point at lat latitude and lon longitude. range and pageid are optional (and range must be specified if pageid is.) JSON:[2,15]
Title Search GET /api/search/title/<string:text>/<int:pageid> Returns model ids as JSON that have text in their title. pageid is optional. JSON:[2,15]
Text Search (b) GET /api/search/text/<string:text>/<int:pageid> Returns model ids that are found with text using PostgreSQL Full Text Search in their title or description. pageid is optional. JSON:[2,15]
Full Search GET /api/search/full (c) Permits combining various criteria to find the exact kinds of models we need. JSON:[432]

Notes

Note Description
a)
{
	"id": 423,
	"title": "Eiffel Tower",
	"lat": 48.8583,
	"lon": 2.2945,
	"desc": "A model of the world famous Eiffel Tower",
	"tags": {
		"shape": "pyramidal",
		"building": "yes",
		"tourism": "attraction",
	}
	"author": "n42k",
	"date": "2017-03-28",
	"categories": ["monuments", "tall"],
	"comments": [
	{
		"author": "n42k",
		"body": "I've technically been here!"
	},
	{
		"author": "n42k",
		"body": "test comment"
	}
	]
}
(b) Might not be implemented for GSoC.
(c) Sample Request Body:
{
	"lat": 48.8583,
	"lon": 2.2945,
	"range": 1000,
	"title": "Eiffel",
	"text": "steel",
	"tags": {
		"shape": "pyramidal",
		"building": "yes"
	},
	"categories": [
		"monuments",
		"tall"
	],
	"page": 1,
	"author": "n42k"
}

Notes:

If any parameter is not specified, it's ignored and won't be filtered from the results.

The "title" attribute does what is described in the "Title Search" endpoint, and the "text" attribute what is described in the "Text Search" endpoint.