6 The subscriptions API is used to manage the podcast subscriptions of a client
13 The Subscriptions API defines the following resources ::
15 /user/{username}/subscriptions
16 /user/{username}/device/{deviceid}/subscriptions
18 The first resource represents the summary of subscriptions over all devices. It
19 can not be modified directly.
21 The second resource represents the subscriptions of a single
22 :ref:`device-integration`.
28 Clients can upload the podcast subscriptions for a :ref:`device-integration` to
29 replace its existing subscriptions.
35 The client sends an object containing all current subscriptions for the
38 PUT /user/{username}/device/{deviceid}/subscriptions
39 Content-Type: application/json
43 { url: "http://example.com/podcast.rss" },
44 { url: "http://podcast.com/episodes.xml" }
52 The server can respond with the following status codes.
54 If a ``Link`` header with ``rel=changes`` is provided, this URL can be used to
55 retrieve changes to the subscriptions since the respective response (see
56 :ref:`subscription-change-download`)
58 If a new device has been created ::
61 Link: <https://api.gpodder.net/user/{username}/device/{deviceid}/subscription?since=0>; rel=changes
66 If the subscriptions have been processed immediatelly ::
69 Link: <https://api.gpodder.net/user/{username}/device/{deviceid}/subscription?since=1234>; rel=changes
74 If the subscriptions have been accepted for later processing ::
80 No change download address is provided in this case, as is is not yet known at
81 the time of the response. If the client needs to know the current
82 subscriptions, it should follow up by a request to download the subscriptions.
84 If invalid podcast information is provided (eg an invalid feed URL), the whole
85 request will be rejected. ::
88 Content-Type: application/json
91 "message": "Invalid podcast URL",
94 "field": "/podcasts/1",
101 Subscription Download
102 ---------------------
104 Clients can download the current subscriptions either of a single
105 :ref:`device-integration` or over all of the user's devices.
111 Download subscriptions of a device ::
113 GET /user/{username}/device/{deviceid}/subscriptions
114 Content-Type: application/json
117 Download all of the user's subscriptions ::
119 GET /user/{username}/subscriptions
120 Content-Type: application/json
126 The podcasts correspond to the :ref:`podcast-type` type. ::
129 Link: <https://api.gpodder.net/user/{username}/device/{deviceid}/subscription?since=1234>; rel=changes
130 Content-Type: application/json
139 The changes link is not provided if all subscriptions of a user are requested.
142 Subscription Change Upload
143 --------------------------
145 Clients can update the current subscriptions of a :ref:`device-integration` by
146 reporting subscribed and unsubscribed podcasts.
152 A client can send which podcasts have been subscribed and unsubscribed. ::
154 POST /user/{username}/device/{deviceid}/subscriptions
155 Content-Tpe: application/json
159 { url: "http://example.com/podcast.rss" }
162 { url: "http://podcast.com/episodes.xml" }
166 A client MUST NOT upload a change set where both ``subscribe`` and
167 ``unsubscribe`` are empty, or where the same podcast is given in both
168 ``subscribe`` and ``unsubscribe``.
174 The server responds with either of the following status codes.
176 The changes are processed immediatelly. ::
179 Content-Tpe: application/json
181 body according to Subscription Download
184 The changes have been accepted for later processing. ::
190 No response body is provided in this case, as it is not yet known.
193 .. _subscription-change-download:
195 Subscription Change Download
196 ----------------------------
198 Download changes to the subscriptions of a :ref:`device-integration`.
204 The client makes the following request. ::
206 GET /user/{username}/device/{deviceid}/subscriptions{?since}
207 Content-Tpe: application/json
213 The server can response with any of the following status codes.
215 The changes are returned immediatelly. ::
218 Link: <https://api.gpodder.net/user/{username}/device/{deviceid}/subscription?since=1234>; rel=changes
219 Content-Type: application/json
223 { url: "http://example.com/podcast.rss" }
226 { url: "http://podcast.com/episodes.xml" }
230 The server can also return a prepared response (see
231 :ref:`prepared-response-api`).
234 Integration Recommendations
235 ---------------------------
237 This section describes how the API can be accessed for common use cases.
239 * On first startup a client CAN retrieve the list of all the user's
240 subscriptions to offer as suggestions.
242 * On first startup a client SHOULD generate a unique :ref:`device-integration`
243 Id for managing its own subscriptions in subsequent API calls.
245 * A client which has been somehow "reset" can re-use an existing device ID and
246 restore its subscriptions from there. It SHOULD NOT share the same device ID
247 with another installation which is still used.
249 * A client SHOULD either use the combination of Subscription Upload and
250 Download endpoints, or the Subscription Change endpoints to keep its
251 subscriptions up to date.
253 * When retrieving subscriptions or subscription changes, a client SHOULD use
254 the URL in the ``Link`` header with ``rel=changes`` (if present) to retrieve
255 subsequent changes to the resource.