Is there an IMWS Endpoint for the IMA "Like" panel in the Navigator?

Started by Jingo, January 25, 2017, 03:13:08 AM

Previous topic - Next topic

Jingo

Hi Mario - trying to come up with a simple way to capture via a script all the images that I have tagged as "Like" in IMA... hoping to create a program that provides a list (with path and some other info) from photos that my wife has tagged using the program (on the couch via her ipad btw - she is a BIG fan of that!!!). 

I was going to tackle this myself by quickly modifying your sample script #4... but in looking at all the Endpoints - they mostly seem like ways to query the database and I didn't see anything specific to the IMA "database"... so, was wondering if there was a way to get at the "Like" info currently. 

Thx in advance! - Andy.

Mario

The "Like" feature is something that only exists in IMatch WebViewer. It is not a IMWS concept.

Likes are managed internally as an "idlist" (a list of file ids). IMatch WebViewer loads and stores this list via the /idlist endpoints.

idlists allow apps to manage lists of file ids of any size "in" IMWS, without the need to transfer them up and down the network all the time. The /files endpoint support an idlist parameter so you can access arbitrary data for all files in a previously created idlist. This Navigator also works that way.

IMatch WebViewer stores the Likes idlist under the name

idlist.likes.<Unique Database ID>.default

1.  If you want to access the files in the idlist you first need to determine the unique id of your database.
IMWS returns that in the respone of the /info endpoint, in the database.uniqueId element.
You can perform an /info request quickly via the "Disvover IMatch WebServices" command in IMatch WebViewer.

Say the unique id of your database is ABCDEFG. Then the Likes idlist will be stored under the name

idlist.likes.ABCDEFG.default

2. You now need to call the /files endpoint with the name of this idlist.

This can be done manually as well. On the "Discover IMatch WebServices" page search for "files". This displays the /files endpoint.
Now go down until you reach the samples and click on the first sample. This performs a /files request for the first 20 files in your database.
More important, it creates a correct /files URL with the current auth_token.

3. Now, replace the id=1-20 part with the idlist parameter: idlist=idlist.likes.ABCDEFG.default
This gives you an URL like

https://your-pc:8081/v1/files?auth_token=3e8735a0811def622d1d9abd1aae9d91d9596be9f43fbeddcb4b4ec89bc9e625&idlist=idlist.likes.ABCDEFG.default

This returns all data for all files in that idlist. If you only want the file name and some other fields, you append a fields parameter:

...&idlist=idlist.likes.ABCDEFG.default&fields=filename,size,datetime

This produces the result you are looking for directly in the web browser.
If you want to do this from scripting, it works exactly the same.  You perform a fetch() on the /files endpoint, supplying the auth_token and the idlist name as the parameters. And maybe a fields parameter to control the data returned. The response IMWS sends to JavaScript looks exactly like what you see in the browser when you do this manually. You can now format the results or do whatevrer you want.

A very nice training project.


-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Voila!  I noticed the /idlist but dismissed it.. whoops!

Thanks Mario... will play with this over the weekend when I have some time... agree it is a great way to learn!  Thx for the starting points... will share the script once complete.  - Andy.

Mario

The next demo I do for the Developer Center will cover how to retrieve file data. I think I will do a simple search box and then display the results in some table. Or maybe as thumbnails (in a demo b).
This is very easy to do because IMWS offers a search endpoint.

Doing these demos is actually fun. But I'm chin-deep in IMatch 2017 (that's the official name, not IMatch 6) at the moment. I use these demos as a useful stress-relief... ;D
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: Jingo on January 25, 2017, 01:59:13 PM
Voila!  I noticed the /idlist but dismissed it.. whoops!

Thanks Mario... will play with this over the weekend when I have some time... agree it is a great way to learn!  Thx for the starting points... will share the script once complete.  - Andy.

Jingo, did you complete your project? I am interested looking into this, to see, how a real  ;D usere does it.
Best wishes from Switzerland! :-)
Markus

Mario

Have you studied the examples in the Developer Center?

I'm a real user too, you know  :)

Or, maybe I'm just a machine intelligence, made of Silicon... :o
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Jingo

Quote from: sinus on March 12, 2017, 10:27:00 AM
Quote from: Jingo on January 25, 2017, 01:59:13 PM
Voila!  I noticed the /idlist but dismissed it.. whoops!

Thanks Mario... will play with this over the weekend when I have some time... agree it is a great way to learn!  Thx for the starting points... will share the script once complete.  - Andy.

Jingo, did you complete your project? I am interested looking into this, to see, how a real  ;D usere does it.

Hello... I actually didn't get the time to complete this yet... been going through some of the Javascript tutorials, reviewing the code samples and playing around with Sublime Text first before just jumping into the IMWS scripting.. figured it might be best to learn some basic swimming moves before jumping straight into the pool!

It is on my list this week though! - Andy.

sinus

Quote from: Mario on March 12, 2017, 12:33:12 PM
Have you studied the examples in the Developer Center?

I'm a real user too, you know  :)

Or, maybe I'm just a machine intelligence, made of Silicon... :o

Thanks, Mario!

You are correct, I thought, you are not a real user, but a superuser or, hmmmmm, made of Silicon, I must think about it.  ;D 8)

I would not say, studied, but looked through you examples. I do this at home, if I have time, in the night on my laptop.

Well, I let run the demos and all worked.
If I am not wrong, the demos 5 and 6 gave me some real thumbs to see, while the other demos gave me some text like keywords and so on.

What I do not know now (well, I have already started some days ago), how I can select say 5 images and then "work" with these 5 images.
Like retrieve some infos from them. Or do other things with them.

So, you see, there are users like me, like Jingo or like you, Mario, and I think, they are not all the same (OK, Jingo, I do not know you  ;D), some have more silicon in the blood like others!  ;D :D

But I think, this could be a good think, this IMatch Anywhere, since I start to understand the system behind it, like it works.

And I can imagine slowly, what can be done with this.
I think, very interesting and with a lot of possibilities.

Best wishes from Switzerland! :-)
Markus

sinus

Quote from: Jingo on March 12, 2017, 01:00:58 PM
Quote from: sinus on March 12, 2017, 10:27:00 AM
Quote from: Jingo on January 25, 2017, 01:59:13 PM
Voila!  I noticed the /idlist but dismissed it.. whoops!

Thanks Mario... will play with this over the weekend when I have some time... agree it is a great way to learn!  Thx for the starting points... will share the script once complete.  - Andy.

Jingo, did you complete your project? I am interested looking into this, to see, how a real  ;D usere does it.

Hello... I actually didn't get the time to complete this yet... been going through some of the Javascript tutorials, reviewing the code samples and playing around with Sublime Text first before just jumping into the IMWS scripting.. figured it might be best to learn some basic swimming moves before jumping straight into the pool!

It is on my list this week though! - Andy.

Thanks, Andy,
very good, a good plan!
If you do it one day, I would be interested anyway.  ;D

I am doing also some first lections lerning to swim (John has encouaged me), but you are miles ahead of me, I am very sure.
And mostly I hesitate to jump into the pool, because I feel the water too cold, while others are swimming and jumping still a long time in the pool.  ::)
Best wishes from Switzerland! :-)
Markus

Mario

Quotehow I can select say 5 images and then "work" with these 5 images.

IMWS has no concept of a "selection".
You could access a file by its name. Or get all files in a folder. Or run a search method to find specific files.
All this gives you a list of file ids, and then you can use these ids to retrieve information about these files, thumbnails etc.

The demos do exactly that. Demo 5, for example.
It searches for files, then displays the file name, date & time and even a thumbnail.
This shows exactly what most users will need.

If you run apps inside IMatch, you have additional features which allow you to get the ids of the files currently selected in the active file window.
If this is what you are thinking about.

The rest is then the same as if you get these ids by asking for the files in a folder, a search result etc.

I recommend you carefully look at the demos, make yourself aquatinted with the text editor and the debugging tools in your browser. Learn a bit about JavaScript and HTML first, them learn how to access IMWS. The side effect is that you can use the same know-how to access other web services as well. All very similar.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: Mario on March 12, 2017, 04:15:52 PM
Quotehow I can select say 5 images and then "work" with these 5 images.

If you run apps inside IMatch, you have additional features which allow you to get the ids of the files currently selected in the active file window.
If this is what you are thinking about.

Thanks, Mario, I will do so, like you wrote, and yes, the demos are very good!

One question though.

I let run your demos simply in a browser (firefox).
But now, without IMatch 2017, how can I let run such a demo inside IMatch?

Must I move the folder (demo5 for example) in the app-folder and can I then find this demo in the app like other apps (tiles and so on)?

Sorry for this basic question, but my doctor found out, there is not the smalles hint of silicon in my blood.  :( ;D
Best wishes from Switzerland! :-)
Markus

Mario

QuoteBut now, without IMatch 2017, how can I let run such a demo inside IMatch?

You cannot. And don't need to.
These demos are designed to be run in a web browser. They don't need any IMatch functionality, only IMWS. They are independent from IMatch.

When IMatch 2017 is out, you can write apps which, in addition to IMWS functionality, also have access to features in IMatch (e.g the file window).

If you now write an app that works with IMWS, it will also work in IMatch 2017. And in any web browser.

An app that uses IMatch functionality will of course run only "in" IMatch.

PS.: Once IMatch 2017 is out, you can use code like this to access the selected files in the file window:

IMatch.get('v1/idlist',{
    name: IMatch.idlist.fileWindowSelection
}).then(function(response) {
   // Do stuff with the files
}


To get information about files from IMWS, you use the /files endpoint. You know that from the demos and the various articles I have posted in recent weeks to get script authors up-to-date.

The /files endpoint needs to know a) which files you want to get data for, b) which data you want to get (file name, size, date & time, metadata, variables, attributes...)

The a) part is simple. You can specify a file name. Or a list of file ids. Or an idlist.

A list of file ids you get e.g. when you ask a folder for its files. Or a category. Or a collection.
You use this idlist and then retrieve e.g. the file name, size, and the contents of the title and keywords tag from IMWS.
Easy. You can see that in the demos, with full details and explanation and working and commented source code.

idlists allow you to store lists of ids (sic!) on the server, for various purposes.
For example, IMatch WebViewer uses an idlist to implement the "Likes" feature. The Likes are stored in an idlist.

And there are some special idlists, e.g. the imatch.all idlist which contains all files in your database.

When an app runs in IMatch, it has access to additional idlists.  In the example above, I used the IMatch.idlist.fileWindowSelection idlist. This idlist always contains all files currently selected in the active file window. You can us it like any other idlist.

For example, to get some information about all currently selected files, you would do

IMWS.get('v1/files',{
idlist: IMatch.idlist.fileWindowSelection,
fields: 'id,name,size'

This returns the id, name and size of all selected files.

IMWS.get('v1/files',{
id: 1,2,3
fields: 'id,name,size'

This returns the same information, for the files 1,2,3

IMWS.get('v1/files',{
path: 'c:\\images\\beach.jpg'
fields: 'id,name,size'


And this returns the same info, for the file c:\images\beach.jpg
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Best wishes from Switzerland! :-)
Markus

Jingo

Hi Mario - got me thinking - is there a list of all standard idlists?  The endpoint list in the IMWS help doesn't display them - only shows that the name is optional.  Thx!

Mario

Quote from: Jingo on March 13, 2017, 12:52:27 PM
Hi Mario - got me thinking - is there a list of all standard idlists?  The endpoint list in the IMWS help doesn't display them - only shows that the name is optional.  Thx!

There are no standard id lists in the available version IMWS. Hence nothing to document.
In the currently available IMWS version, idlists only exist so apps can use them.

IMatch 2017 builds on that concept and provides currently two id lists.
These are documented in the documentation of the IMatch class of course.
All this will be included in IMatch 2017.

Excerpt from the IMatch class library documentation:



I most likely add additional "automatic" idlists, for example, selectedFolders, selectedCategories, selectedCollections, selectedTimelineNodes. This create neat and easy to use way to use selections with endpoints like /folders or /categories.

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook