Page 1 of 1

serviidb restful api

PostPosted: Thu Feb 16, 2012 1:53 pm
by moltra
I am starting to work on the restful api. Let me know what you guys think. I have already gotten some feedback from Will.


will wrote:Yes I should send one request and get everything back in one go

At first lets just go for me sending the title that I want (ignore case but match ordering) with optional filters. Later we could expand it so that I can query for a list of services

e.g
1) "the simpsons" will return all feeds with "the simpsons" might give 4oD - The Simpsons and Hulu - The simpsons
2) "the simpsosn" plus filters e.g. region=GB will just give 4oD - The Simpsons

so the request for 2) would look like title="the simpsons", region="GB"

Ideally, I will be able to call /rest/langages and /rest/regions to get a list of the avialable ones which I can then present via a drop down box for users. Might be worth moving this to a thread on the serviio forum so that we can partially involve zip in doing the spec for the queries.

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 2:05 pm
by will
Before we start this, could you list all the database fields that you have and then we can list what we would want to filter against.

At first it will be a simple search, but I could see a more advanced browse serviidb activity in the future where users can filter through the content.

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 4:22 pm
by zip
will it include the plugin as well if needed? the API could return a zip package including the plugin and description data as a bundle and I'd add an API to store the plugin in the plugins folder.

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 7:50 pm
by moltra
That is what we are discussing what all it needs to do. Yes I think we can include the plugin if needed.

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 8:13 pm
by will
Will installing plugins support a url, or will it be local only?

As per my post in one of the earlier threads, having access to the installed plugins (and their versions) will also be very useful as I can then say to the user, you also need to install this, or you need to update this first.

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 8:46 pm
by moltra
will wrote:Will installing plugins support a url, or will it be local only?
I am not sure what you mean?

I think it would probably be the safest, to have a resource to download the file and then the requesting app would copy it to the desired folder.

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 9:14 pm
by moltra
Has anyone used a XMLRPC server. I can use a REST server or a XMLRPC server.

The reason I am asking is that last night at work, I enabled the XMLRPC server and keep on working on the site. Then I saw that I did not have the REST server enabled so I enabled it and disabled the XMLRPC server. As soon as I hit save configuration, I got bounced off the site due to my companies firewall. So basically if I use REST server, I will not be able to even login at work (work 12 hours sitting at desk with nothing to do most of the time), or if I use the XMLRPC server I can keep working on the site entering data and maintaining the database.

If the REST server is best for connecting to the database then that would be how it is.

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 9:33 pm
by will
Personally I would prefer REST as it means I don't need another library and json is so easy to work with.

Can you not make changes through the site while the rest server is enabled?

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 9:44 pm
by moltra
I can make changes to the site from home with the Rest server is running, but not at work, I hit the firewall as soon as I enabled the rest server.

But once I get the site up the way we like it I will not be connecting to it that much at work.

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 10:20 pm
by zip
That's weird, REST is just HTTP protocol, usually even on port 80, so like normal browsing. Definitely REST, if it's nor REST I won't even bother :-D

Re: serviidb restful api

PostPosted: Thu Feb 16, 2012 10:35 pm
by moltra
I am off until Saturday, I will try it again.

Re: serviidb restful api

PostPosted: Fri Feb 17, 2012 8:58 am
by moltra
I have the REST server up. Here is some of the information about it. Let me know if you need anything changed or added. I am trying to figure out how to add a search.

  Code:
$endpoint = new stdClass;
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'rest';
$endpoint->server = 'rest_server';
$endpoint->path = 'rest';
$endpoint->authentication = array(
  'services' => 'services',
);
$endpoint->server_settings = array(
  'rest_server' => array(
    'formatters' => array(
      'bencode' => TRUE,
      'ical' => TRUE,
      'json' => TRUE,
      'jsonp' => TRUE,
      'php' => TRUE,
      'plist' => TRUE,
      'rss' => TRUE,
      'xcal' => TRUE,
      'xml' => TRUE,
      'xmlplist' => TRUE,
      'yaml' => TRUE,
    ),
    'parsers' => array(
      'application/json' => TRUE,
      'application/plist' => TRUE,
      'application/plist+xml' => TRUE,
      'application/vnd.php.serialized' => TRUE,
      'application/x-www-form-urlencoded' => TRUE,
      'application/x-yaml' => TRUE,
      'multipart/form-data' => TRUE,
    ),
  ),
);
$endpoint->resources = array(
  'comment' => array(
    'alias' => 'comment',
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'index' => array(
        'enabled' => 1,
      ),
    ),
    'actions' => array(
      'countAll' => array(
        'enabled' => 1,
      ),
      'countNew' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'file' => array(
    'alias' => 'file',
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'index' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'node' => array(
    'alias' => 'node',
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'index' => array(
        'enabled' => 1,
      ),
    ),
    'relationships' => array(
      'files' => array(
        'enabled' => 1,
      ),
      'comments' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'system' => array(
    'alias' => 'system',
    'actions' => array(
      'connect' => array(
        'enabled' => 1,
      ),
      'get_variable' => array(
        'enabled' => 1,
      ),
      'set_variable' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'taxonomy_term' => array(
    'alias' => 'term',
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'index' => array(
        'enabled' => 1,
      ),
    ),
    'actions' => array(
      'selectNodes' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'taxonomy_vocabulary' => array(
    'alias' => 'vocabulary',
    'operations' => array(
      'retrieve' => array(
        'enabled' => 1,
      ),
      'index' => array(
        'enabled' => 1,
      ),
    ),
    'actions' => array(
      'getTree' => array(
        'enabled' => 1,
      ),
    ),
  ),
  'user' => array(
    'alias' => 'user',
  ),
);
$endpoint->debug = 1;

Re: serviidb restful api

PostPosted: Sat Feb 18, 2012 5:33 pm
by Xmantium
zip wrote:That's weird, REST is just HTTP protocol, usually even on port 80, so like normal browsing. Definitely REST, if it's nor REST I won't even bother :-D

Zip has REST his case :lol: (it was more funnier in my head)

Good work moltra. Just to note aswell, each URL should also specify weather it HD or SD
Have you figured out the maximum thumbnail resolution size for video streams?

Re: serviidb restful api

PostPosted: Sat Feb 18, 2012 6:32 pm
by moltra
Xmantium wrote:Good work moltra. Just to note aswell, each URL should also specify weather it HD or SD
Have you figured out the maximum thumbnail resolution size for video streams?


should the URL have the HD/SD or should you be able to sort a list of feeds by HD/SD?

I have the following fields setup to allow sorting by it. Drupal the Content Management System (CMS) I am using calls them Taxonomy terms.

Category (movie, music,video feed/art,youtube) plus more to be added as needed.

Region (US, UK, Germany, Worldwide) more added as needed.

Language
Media Source (RSS, Web Resource)
Media Type (Audio,image,video)
Plugin (none,name_rev)
Resolution(SD,HD)

I am not sure that I want to put all those terms in the URL. That is why I have it setup right now like the following.

http://serviidb.com/video-feeds/wildlife/nature-pbs

It says it is a video feed, about wildlife and the name is Nature-pbs.

I could change it to
  Code:
http://serviidb.com/video-feeds/wildlife/HD/nature-pbs

but then should I make it like the following
  Code:
http://serviidb.com/video-feeds/wildlife/HD/US/worldwide/nature-pbs


Since I have 7 terms at this time that I can sort/filter on do we need to add some or all to the URL?

Have you figured out the maximum thumbnail resolution size for video streams
What are you asking about the max thubmnail resolution size? Right now the site only takes what you input into it and it converts it to a thumbnail 160x120. Are you talking about making that size bigger?

Re: serviidb restful api

PostPosted: Sat Feb 18, 2012 7:35 pm
by zip
I'd make it easy -

  Code:
.../search?query=the+simpsons


for optional filters you can add


  Code:
.../search?query=the+simpsons&region=uk&q=sd

Re: serviidb restful api

PostPosted: Sat Feb 18, 2012 7:36 pm
by zip
zip wrote:I'd make it easy -

  Code:
.../search?query=the+simpsons


for optional filters you can add


  Code:
.../search?query=the+simpsons&region=uk&q=sd


You could filter on resource type (feed, libe, etc), but the user is hardly interested in this.

Re: serviidb restful api

PostPosted: Sat Feb 18, 2012 7:56 pm
by moltra
zip wrote:
zip wrote:I'd make it easy -

  Code:
.../search?query=the+simpsons


for optional filters you can add


  Code:
.../search?query=the+simpsons&region=uk&q=sd


You could filter on resource type (feed, libe, etc), but the user is hardly interested in this.


I will work on the REST search tomorrow at home, I can get to the site through a remote desktop to a terminal server inside the company network, but cannot from my computer. Strange the firewall should be the same.

Re: serviidb restful api

PostPosted: Sat Feb 18, 2012 9:59 pm
by kairoh
If you want an example of a successful REST website, there is this one and its documentation.
You may copy some idea. ;)

Re: serviidb restful api

PostPosted: Sat Feb 18, 2012 11:00 pm
by moltra
Thanks I will look at it this evening, I am new at building a REST server.