bpatrik / pigallery2

A fast directory-first photo gallery website, with rich UI, optimized for running on low resource servers (especially on raspberry pi)
http://bpatrik.github.io/pigallery2/
MIT License
1.7k stars 195 forks source link

API Examples #200

Open Payero opened 3 years ago

Payero commented 3 years ago

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

LorenzBischof commented 3 years ago

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

Payero commented 3 years ago

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 notifications@github.com 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.

bpatrik commented 3 years ago

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 notifications@github.com 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 < notifications@github.com> 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 .

nishantbb commented 3 years ago

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?