I've started to use PhotoStationon my Synology NAS device at home to organize my photosand provide easy means to access remotely. I have been quite pleased overall, especiallywith the integration with the DS Photo app which can sync photos from an iPhone's cameraroll to the Synology NAS.
- Iphone Photo Sync Synology Software
- How Do I Sync My Iphone Photos With Synology
- Iphone Photo Sync To Synology
- Iphone Synology Photo Backup
I was looking for an automated way to sort my photos into a hierarchy of folders by date.Unable to find a built-in way to do this or any public documentation for the PhotoStation API, Iset about to explore the API and see what I could figure out.
Synology API Structure
Synology iCloud photo sync Backing up iCloud Photos to a Synology NAS - Adrian Thoma. I; External 2TB hard drive; Synology 4-bay NA; Hi I an a new user of Synology, operating in a Mac environment and having backed up all files to iCloud. To be sure to be sure i. How to use PhotoSync with a Synology NAS? To use PhotoSync with FTP, you need to configure the NAS for FTP access. Open the Control Panel, go to the File Services section into the.
While the Synology developer documentation sitedoes not have any API reference for PhotoStation, it does contain information on some of the otherREST APIs from Synology which proved useful to understanding the basicworkings of the PhotoStation API.For example, in the documentation for FileStationone can see how the general request/response workflow is for a Synology application.
Each application has several named APIs (eg. SYNO.FileStation.Info or SYNO.FileStation.List)that provide different functionality. To make a request against one of these APIs,one must first find its endpoint (the path portion of the URL) and then send anHTTP request with the following parameters:
api- API namemethod- name of method being invokedversion- version of API being accessedsid- session ID received during login step
The API endpoints and available versions can be found by querying theSYNO.API.Info API at http://mysynology:5000/webapi/query.cgi. Sending arequest with the above parameters (sans sid) and additional parameterquery=all will return a list of all available APIs from the NAS device.
Unfortunately, there are no PhotoStation APIs listed in the response. This,as it turns out, is because the PhotoStation API is handled differently, as we see below.
Listening on the Wire
Since the FileStation documentation didn't lead to the list of APIs as I hoped,the next step was to examine the network traffic between the browser and NAS when runningPhotoStation. Since the web interface for PhotoStation does not use HTTPS by default, it is rathereasy to use a packet tracing tool like wireshark toexamine the network traffic between my browser and the NAS system. By settinga capture filter to 'host 10.20.30.40 and port 80' (the IP of my NAS device) and thenusing a display filter 'http', I could start to see the HTTP traffic between thejavascript UI running in my browser and the PhotoStation backend.
Alternatively, one could use developer tools in thebrowser itself to show the network requests and responses being sent from a particular session.The built-in browser tools can be easier to understand than wireshark but only works (obviously)when using that browser. Later on, when doing testing from the command line with curlwireshark is useful (though curl too can display some additional info with the -v flag)
The first thing to notice when looking at the network traffic from a browser is that theall the requests are going to port 80 on the NAS and not port 5000 where the DSM GUI operates.Secondly, there appeared to be two broad sets of requests - those going to files in /photo andthose accessing files in /photo/webapi. The first are all the files for displaying andrunning the PhotoStation GUI. The latter set are requests to the backend API. Finally, theobserved /photo/webapi calls all (or mostly all) appeared to have .php suffixes.
Given this, a quick trial shows that there is a separate API info endpointfor PhotoStation that can be accessed as follows:
The response (truncated below, see full response here)lists approximately 30 separate APIs along with their path (endpoint) and versions:
Understanding Authentication

Having made some progress, the next step was to tackle authentication. None of thebackend requests I observed had a sid or session parameter mentioned in theFileStation documentation, so it was unclear how an authenticated session wascommunicated to the backend.
I experimented some with curl to try to mimic the queries that were beingsent by my browser but would get different results or errors because itdid not recognize my session. Even copying the SynoToken parameter thatwas sent on some backend queries did not help.
In the end, I discovered that session ID was being sent as a cookie (withthe key PHPSESSID) on each request. Once I started to send a similar cookiein curl (with the -b KEY=VALUE option), I could start getting thesame responses via curl as from the browser.
However, I still needed to understand how to start a session (ie. login) ratherthan piggyback on an existing session. The login method of SYNO.PhotoStation.Authcertainly seemed promising but without knowing the parameters to send, itdoesn't do much good. Fortunately, I was able to log out of PhotoStation andthen login again while tracing the network and was able to see the neededparameters (username and password).
Iphone Photo Sync Synology Software
Sending my credentials to this API returned (among other items) a session IDthat I could use to send in cookie form on subsequent requests.
Diving into the Code
Tracing requests and responses can be informative but does not always give insightinto the meaning of parameters or even the existence of parameters not beingused by the GUI. Thankfully, I was able to also dig into the PhotoStation code some.
Synology's NAS products are based on Linux and they provide local shell access throughssh. With this, one can log into the NAS and explore what is going on. Unfortunatelyit takes a while to find where things are.

Synology Packaging

Synology applications are distributed in packages, bundled archives of files that providethe necessary code and data to run an application. When installed on a Synology machinethese packages are unpacked into a subfolder in /var/packages named for theapplication, for instance /var/packages/PhotoStation.Within this package directory there are a number of files and directories that pertainto the packaging itself (eg. versioning, install/upgrade/remove scripts, etc…) whilethe core application code and data are saved in a target directory.
Synology only allocates a few GB to its operating system, so this target directory istypically a symlink to another directory within one of the storage volumes, /volume1/@appstore/PhotoStationin this case. Within this directory are all the files used by PhotoStation – all 3700+ of them!While a daunting number to examine, there is a silver lining … one reason why there areso many files is that the backend REST API is written in PHP, and thus is present inreadable code on the NAS device (unlike other applications that might have only compiled binariesinstalled).
Exploring photo/webapi Directory
The photo/webapi directory within /var/packages/PhotoStation/target contains the bulkof the PHP code used in the backend of PhotoStation. These are the files that thewebserver calls to handle requests. For instance, a request to http://mysynology/photo/webapi/auth.phpwill run the PHP script contained in photo/webapi/auth.php. Knowing this, one can explorethe individual code for each command.
In addition to these PHP files, there are additional files located in photo/include and photo/webapi/sdkthat may be referenced by the PHP files in photo/webapi.
How Do I Sync My Iphone Photos With Synology
Finally, there is a file named photo/webapi/PhotoStation.api that provides the sameinformation as the SYNO.API.Info query (API name, path and versions) but also providesa list of all the methods associated with an API!
Here is a small subset of the APIs defined in photo/webapi/PhotoStation.api:
Documenting the API
With this information, wireshark and time to experiment and test, I was able togradually understand some of the key parts of the PhotoStation API - notably thoseparts associated with creating albums, moving photos and the like. Initially,I was taking notes in a small text file but soon I was inspired to take it a stepfurther and started my ownunofficial Synology PhotoStation API documentation usingthe wonderful TechDoc Hugo theme.
I've tried to lay out the basics for using the API in the Getting Startedsection. This should, hopefully, allow others to get up to speed with accessingthe API directly. The API Reference sectionprovides detailed information on a limited number of APIs (as I have been able toexamine and document them). Within this section, I provide information on therequest parameters and the responses for various methods of the APIs.
I don't expect I will completely document the entire API, as frankly there are onlya limit subset of calls required for my immediate project. However, I as I understandthe API more, I will try to update this documentation for others. I've hosted thedocumentation on GitHub at https://github.com/jamesbo13/syno-photostation-api andwould be open to any pull request improvements.
Iphone Photo Sync To Synology

Iphone Synology Photo Backup
| Bash Command-line Completion with Go | Remote Time Machine for Multiple Macs |
