Faucet API Specification

Faucet provides a REST API at the url: http://www.vcast.it/faucetpvr/api/1.0/server_rest.php

The user access credential (username and password) are present in every API call as part of the HTTP HEADER of the request according to the basic authentication criteria, as defined by RFC2617, an example of the header line is:
Authorization: Basic ZnJlZDp0aGF0cyBtZQ==
Where the ending string is the pair <username>:<password> coded base64
Client applications using the API can perform the following operations:

1 - Get the channels list.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/channels
	method:		GET
	Querystring: 	type=video
	Returns:	200 OK & JSON object containing the array of the channels
			401 Unauthorized
The client can set a filter on the channel type (radio or tv), but currently the request returns the whole list containing both types in any request. That's because the list parsing is performed by the client.
The JSON object is an array whose elements are made up with two fields describing the stream:
- name : the name of the channel
- type : the type can be only video (a tv channel)
To better clarify the structure of the channels array here is an example of the JSON object provided by the server:
[ {"name":"Rai1","type":"video"},
  {"name":"Rai2","type":"video"},
  {"name":"Rai3","type":"video"},
                ......                ]
2 - Get the recordings list.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/recordings
	method:		GET
	Querystring: 	no parameters needed
	Returns:	200 OK & JSON object containing the array of the recordings
			401 Unauthorized
The JSON object is an array whose elements are the parameters describing the recording:
- id_rec : identification number of the recording
- channel : channel name
- channel_type : channel type (video)
- title : name of the recording
- from_time : start time
- to_time : end time
- rec_time : duration of the recording
- repeat : periodicity of the recording (not repeated/daily/weekly/from monday to friday/from monday to saturday)
- retention :
- format : media format
- faucetacc : url for opening the faucet modification page for the recording

An example of the JSON object returned by the server is the following:
[ 
  {
   "id_rec":"411202",
   "channel":"Rai2",
   "channel_type":"video",
   "title":"Mattino",
   "from_time":"2008-02-04 09:00:00",
   "to_time":"2008-02-04 10:00:00",
   "rec_time":"00:00",
   "repeat":"no_repeat",
   "retention":"3",
   "format":"mp3",
   "faucetacc":"http://www.vcast.it/faucetpvr/update.php?qwt=w=HMgTzN"
  },

  {
   "id_rec":"411201",
   "channel":"Rai1",
   "channel_type":"video",
   "title":"Tg1",
   "from_time":"2008-02-04 20:00:00",
   "to_time":"2008-02-04 20:30:00",
   "rec_time":"00:00",
   "repeat":"daily",
   "retention":"3",
   "format":"portable",
   "faucetacc":"http://www.vcast.it/faucetpvr/update.php?qwt=w=NRUTzN"
  },

  {
   "id_rec":"411204",
   "channel":"La7",
   "channel_type":"video",
   "title":"Reservoir dogs",
   "from_time":"2008-02-04 21:00:00",
   "to_time":"2008-02-04 23:30:00",
   "rec_time":"00:00",
   "repeat":"no_repeat",
   "retention":"3",
   "format":"h264",
   "faucetacc":"http://www.vcast.it/faucetpvr/update.php?qwt=w=TMQTzN"
  }
]
3 - Create a new recording.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/recordings
	method:		POST
	Request Body:	JSON object containing the parameters of the recording to add.
	Returns:	201 Created
			400 Bad request in those cases in which some of the parameters are 
                            not provided, or the channel type is not 'video', 
                            or if the recording time is longer than 3 hours.
			401 Unauthorized
Note that different error cases that rise a 400 HTTP message are checked on client side and notified to the user before the insert HTTP request is sent.
An example of the JSON object sent to the server to specify a new recording insertion is:
{
 "from_time":"2008-02-04 11:00:00",
 "ch_name":"Mtv",
 "to_time":"2008-02-04 12:30:00",
 "ch_type":"video",
 "retention":"3",
 "repeat":"no_repeat",
 "format":"portable",
 "title":"Into the music"
}
The allowed value for the different field are:
ch_type can be 'video'
format can be 'portable', 'divx', 'mp3', 'h264'
repeat can be 'no_repeat', 'daily', 'weekly', 'mon_fri', 'mon_sat'

The field retention and format are not mandatory, if not present the default for yhe user will be inserted.

4 - Modify an existing recording.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/recordings
	method:		POST
	Request Body:	JSON object containing the parameters of the recording to change, and the id 
                        of the recording that is going to be modified
	Returns:	200 OK
			401 Unauthorized
			500 Internal server error in case some modification errors occur (that is any 
                            error that can occur during the insert method, used in conjuction with the 
                            delete method to do the modify)
An example of the JSON object sent to the server to specify the modification of some given parameters is:
{
 "id_rec":"411206",
 "ch_type":"video",
 "repeat":"weekly",
 "from_time":"2008-02-04 12:30:00",
 "ch_name":"Mtv",
 "retention":"3",
 "title":"Into the music",
 "format":"portable",
 "to_time":"2008-02-04 11:00:00"
}
5 - Delete an existing recording.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/delete_recording
	method:		GET
	Querystring: 	id_rec identification number of the recording to delete
	Returns:	200 OK (Delete Done)
			401 Unauthorized
			404 Not found if the user tries to delete a non-existent recording
6 - Return Faucet RSS feed for the user.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/feed
	method:		GET
	Querystring: 	no parameters needed
	Returns:	200 OK & JSON object containing the URL for the Faucet RSS feed (podcast) 
                            containing the recorder items
			401 Unauthorized
An example of the JSON object returned by the server is the following:
{
 "feed_url":"http://www.vcast.it/JPodcast/Vfaucet/........"
}
7 - Return Faucet internal user identifier.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/faucetid
	method:		GET
	Querystring: 	no parameters needed
	Returns:	200 OK & JSON object containing Faucet unique id_usr
			401 Unauthorized
An example of the JSON object returned by the server is the following:
{
 "id_usr":"411202"
}
8 - Return the URL that publishes the list of the active recording criteria.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/activerecfeedurl
	method:		GET
	Querystring: 	no parameters needed
	Returns:	200 OK & JSON object containing the array of the recordings
			401 Unauthorized
An example of the JSON object returned by the server is the following:
{
 "active_rec_url":"http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/activerecordings?K=yreorpeutrreuqirpqwiu"
}
9 - Enable a faucet user.
	URL: 		http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/enableuser
	method:		GET
	Returns:	200 OK (Enable user done)
			401 Unauthorized
			400 Faucet user already exists

A simple way to test the APIs and to get some confidence with them is to use the curl command in this way:
curl --user YOUR_USER:YOUR_PASSWORD http://www.vcast.it/faucetpvr/api/1.0/server_rest.php/API_NAME



To better using these APIs, a developer (external to VCast team), has create a Java wrapper. More infos can be found at his project page:
http://code.google.com/p/vcastjavaapi

Faucet API License

VCAST FAUCET, API LICENSE AGREEMENT
By using the VCAST's APIs (APIs) on the VCAST website ("www.vcast.it") you agree to be bound by the terms of this API Licence ("the Licence") and VCAST service usage.
1. Licence terms
VCAST grants to You a non-commercial, world-wide, payment-free, non-exclusive, non-sublicensable right to copy, reproduce, download and/or publish the API's and alter, adapt, edit, incorporate, modify, translate and create your own product or services based on the API's (a 'Work') provided that You shall:
a. only use the API's for your own personal, non-commercial use;
b. acknowledge the source of the API's in your Work with the following credit: "powered VCAST"
c. notify VCAST of the URL at which your Work can be viewed by VCAST and by the users of the VCAST websites.
d. not publish, distribute or otherwise make the APIs available, (including in any Work You create), in a way that would enable other people to download or use the APIs other than as set out in this Licence.
e. only use the APIs and/or the Work for purposes that are not illegal, derogatory or otherwise objectionable or that bring VCAST or any third party into disrepute.
f. not infringe any third party's intellectual property rights nor remove, obscure, or alter any VCAST copyright notice, trademarks, or other notices (including the terms of this Licence) included in the APIs.
g. you shall not create or use any script or tool that enables you to poll the API more than once every 5 seconds.
h. use development keys (if provided) and acknowledge that use of the development key shall signify Your agreement to the terms of this Licence. If no development key is provided to You then the use of the API shall signify your agreement to these License terms.
i. any other use of the API's requires the prior written permission of VCAST. Please e-mail info@vcast.it
2. Intellectual Property
VCAST shall, subject to the licence granted in Paragraph 1 above, retain all right, title and interest including intellectual property rights in the API's including in the VCAST copyright notice and VCAST trademark(s). VCAST shall not own any software You create in producing the Work, nor any third party components incorporated by You, in accordance with the terms of this Licence, into the Work.
3. No Endorsement
You agree that nothing in this Licence shall be construed by You as an endorsement of You or Your Work by VCAST and You agree not to directly or indirectly infer in or from Your Work any such endorsement or support by VCAST.
4. Disclaimer of Warranties
VCAST expressly disclaims all responsibility for any loss or damage arising out of or in connection with your use of the API's. The VCAST API's are provided 'as is' and on an 'as available' basis and to the fullest extent permitted by law VCAST disclaims all express or implied warranties.
5. Indemnity
You hereby agree to indemnify, hold harmless and defend VCAST in respect of all damages, costs and expenses, including reasonable legal fees and litigation expenses, arising out of or as a result of any breach by You of the terms of this Licence or otherwise in connection with your use of the API's.
6. Termination
You may terminate this Licence at any time by destroying or removing all instances of VCAST data gathered using the API including any VCAST data incorporated in Your Work, however and wherever the Work is stored or hosted.
7. General
If any provision of this Licence is held to be invalid or unenforceable, it shall not affect the validity or enforceability of the remainder of the terms of this Licence
A person who is not a party to this Licence will have no rights under the Contracts.
This Licence shall be governed by Italian law and the Italian courts shall have exclusive jurisdiction to settle any claim or dispute which may arise