Jump to content

RESTful API design help


Andy-H

Recommended Posts

Hi, I want to write a RESTful API to interface with our tracking units database, I was just wondering, which of the following would be closest to RESTful design:

 

 

To request a journey:

/devices/identifier/journeys/start_date/end_date

/devices/identifier/journeys/journeyID

 

 

or

 

 

/journeys/device_identifier/start_date/end_date

/journeys/journeyID

 

Thanks for any help.

Link to comment
https://forums.phpfreaks.com/topic/265412-restful-api-design-help/
Share on other sites

Just as a little-more in-depth explanation:

 

 

I am unsure as to which way to go here as a journey is an entity in itself (a collection of latlng locations, grouped with speed, bearing etc.) but it belongs to a device, i.e. can not exist without being created by (and linking to) a device, I am only just learning about REST and don't know what to do in this situation to conform to it.

 

 

I'm not bothered about strictly conforming to REST, i.e. supplying cache information with date etc. but would like to follow the url structure, idea of GET/PUT/POST/DELETE and HTTP response code error reporting.

 

 

 

 

RESTful means you use HTTP verbs GET/POST/DELETE.

 

So

 

To request a journey:

/devices/identifier/journeys/start_date/end_date

/devices/identifier/journeys/journeyID

 

or

 

/journeys/device_identifier/start_date/end_date

/journeys/journeyID

 

Is both restful. Even foo.php?bar=bat is restful.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.