17
1 India, Feb 2013 REST, JSON APIs Geo2tag interface description

Json protocol, Geo2tag REST API fundamentals

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Json protocol, Geo2tag REST API fundamentals

1

India, Feb 2013

REST, JSON APIsGeo2tag interface description

Page 2: Json protocol, Geo2tag REST API fundamentals

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.

Page 3: Json protocol, Geo2tag REST API fundamentals

3

India, Feb 2013

Goals of REST

● Scalability of component interactions● Generality of interfaces● Independent deployment of components● encapsulate legacy systems

Page 4: Json protocol, Geo2tag REST API fundamentals

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.

Page 5: Json protocol, Geo2tag REST API fundamentals

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

Page 6: Json protocol, Geo2tag REST API fundamentals

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]

}

Page 7: Json protocol, Geo2tag REST API fundamentals

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"}

Page 8: Json protocol, Geo2tag REST API fundamentals

8

India, Feb 2013

Invoking by curl

$ curl -d '{"login":"Mark","password":"test"}' http://india.geo2tag.org/service/login

Page 9: Json protocol, Geo2tag REST API fundamentals

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, ...}

Page 10: Json protocol, Geo2tag REST API fundamentals

10

India, Feb 2013

Live example

Page 11: Json protocol, Geo2tag REST API fundamentals

11

India, Feb 2013

Command security

● Plain commands (version, build,...)● Session management

– login

– closeSession

● Authorized commands– With session token

Page 12: Json protocol, Geo2tag REST API fundamentals

12

India, Feb 2013

Session workflow

● Check version● Acquire session token● … R/W tags, channels ● Close session

Page 13: Json protocol, Geo2tag REST API fundamentals

13

India, Feb 2013

Login

● /login– login

– password

Page 14: Json protocol, Geo2tag REST API fundamentals

14

India, Feb 2013

User management

● /addUser– login

– password

– Email

● /deleteUser– login

Page 15: Json protocol, Geo2tag REST API fundamentals

15

India, Feb 2013

Channel Management

● /addChannel– name

– description

– url

– radius

● /owned● /subscribe● /subscribed

Page 16: Json protocol, Geo2tag REST API fundamentals

16

India, Feb 2013

Working with tags

● /writeTag– channel

– description

– {coordinates}

– time

– title

● /loadTags– latitude

– longitude

– radius

Page 17: Json protocol, Geo2tag REST API fundamentals

17

India, Feb 2013

Contacts

[email protected]