Upload
kirill-krinkin
View
527
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
1
India, Feb 2013
REST, JSON APIsGeo2tag interface description
2
India, Feb 2013
RESTful API
● REST = Representational State Transfer– 2000 by Roy Fielding
– The model of http (v 1.0)
– HTTP POST is being used for communication.
3
India, Feb 2013
Goals of REST
● Scalability of component interactions● Generality of interfaces● Independent deployment of components● encapsulate legacy systems
4
India, Feb 2013
Java script Object Notation
● Text-based, Object-oriented, data interchange format.
● Structure:– A collection of name/value pairs
– Ordered list of values.
5
India, Feb 2013
Grammar
● Begin-array – [ left square bracket● Begin-object – { left curly bracket● End-array – ] right square bracket● End-object – } right curly bracket● Name-separator – : colon● Value-separator – ; , comma
6
India, Feb 2013
Examples
{
"Image": {
"Width": 800,
"Height": 600,
"Title": "View from 15th Floor",
"Thumbnail": {
"Url": "http://www.example.com/image/481989943",
"Height": 125,
"Width": "100"
},
"IDs": [116, 943, 234, 38793]
}
7
India, Feb 2013
Geo2tag REST API
Based on JSON objects interchange● Command:
– URI● Service URL● Function
– Parameters: JSON object
Example
URI http://india.geo2tag.org/service/login– Params (Json): '{"login":"Mark","password":"test"}
8
India, Feb 2013
Invoking by curl
$ curl -d '{"login":"Mark","password":"test"}' http://india.geo2tag.org/service/login
9
India, Feb 2013
Session tokenclient server
/version
{“errno”: 0, “version” : “1.02”}
/login {“login” : “user”, “password”:”pwd”}
{“errno”: 0, “auth_token” : “765888876588”}
/loadTags {“auth_token” : “765888876588”, “latitude”:23.0, ”longitude”:12.0, “radius”: 5}
{“errno”: 0, ...}
10
India, Feb 2013
Live example
11
India, Feb 2013
Command security
● Plain commands (version, build,...)● Session management
– login
– closeSession
● Authorized commands– With session token
12
India, Feb 2013
Session workflow
● Check version● Acquire session token● … R/W tags, channels ● Close session
13
India, Feb 2013
Login
● /login– login
– password
14
India, Feb 2013
User management
● /addUser– login
– password
● /deleteUser– login
15
India, Feb 2013
Channel Management
● /addChannel– name
– description
– url
– radius
● /owned● /subscribe● /subscribed
16
India, Feb 2013
Working with tags
● /writeTag– channel
– description
– {coordinates}
– time
– title
● /loadTags– latitude
– longitude
– radius
–