pigallery2 icon indicating copy to clipboard operation
pigallery2 copied to clipboard

API Examples

Open Payero opened this issue 4 years ago • 4 comments

Patrik, Huge fan of Pi Gallery 2, it does exactly what I needed to do. After reading some of the features in the README file I saw the ability to get random pictures: Random photo url You can generate an url that returns a random photo from your gallery. You can use this feature to develop 3rd party applications, like: changing desktop background

Can you provide information about how to use the API for this and other features? I could not find how to send this request to the server.

Thanks, Oscar

Payero avatar Oct 28 '20 11:10 Payero

There is a dropdown in the upper right corner. I generated this one in the demo: https://pigallery2.herokuapp.com/api/gallery/random/?directory=.&recursive=true randomlink

LorenzBischof avatar Oct 28 '20 11:10 LorenzBischof

I was hoping for an API where I can see the options to generate the request.  I am Ok if it does not exists, it just that I wanted to use that feature.  I wanted to do it dynamically rather than using the dropdown menu. On Wednesday, October 28, 2020, 07:48:43 AM EDT, lbischof [email protected] wrote:

There is a dropdown in the upper right corner. I generated this one in the demo: https://pigallery2.herokuapp.com/api/gallery/random/?directory=.&recursive=true

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Payero avatar Oct 28 '20 13:10 Payero

You should be able to dynamically create the link. It works with HTTP GET. This file contains the supported parameters: https://github.com/bpatrik/pigallery2/blob/master/src/common/entities/RandomQueryDTO.ts

This is the middleware that pareses that HTTP GET: request: https://github.com/bpatrik/pigallery2/blob/ee1ce3402480514f2f6e4c4eee16fb99d92f721f/src/backend/middlewares/GalleryMWs.ts#L117 And here is the business logic for that: https://github.com/bpatrik/pigallery2/blob/ee1ce3402480514f2f6e4c4eee16fb99d92f721f/src/backend/model/database/sql/GalleryManager.ts#L86

Sorry there is no official API documentation for it, but it should be simple to reverse engineer it. (You just append the parameter-value pairs to the end of https:///api/gallery/random/? https://pigallery2.herokuapp.com/api/gallery/random/?directory=.&recursive=true with separating them with a &, like: https://pigallery2.herokuapp.com/api/gallery/random/?directory=.&recursive=true from above)

Patrik

Payero [email protected] ezt írta (időpont: 2020. okt. 28., Sze, 14:23):

I was hoping for an API where I can see the options to generate the request. I am Ok if it does not exists, it just that I wanted to use that feature. I wanted to do it dynamically rather than using the dropdown menu. On Wednesday, October 28, 2020, 07:48:43 AM EDT, lbischof < [email protected]> wrote:

There is a dropdown in the upper right corner. I generated this one in the demo: https://pigallery2.herokuapp.com/api/gallery/random/?directory=.&recursive=true

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bpatrik/pigallery2/issues/200#issuecomment-717929097, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZKA5QHZUEL3M646ZJ7BWDSNALL3ANCNFSM4TCFXUEQ .

bpatrik avatar Oct 28 '20 13:10 bpatrik

When I use these links I receive a 404 when the browser requests the favicon. Is it possible to add the default favicon for PiGallery2 to these links?

nishantbb avatar Mar 25 '21 20:03 nishantbb