-
Notifications
You must be signed in to change notification settings - Fork 18
/
apiary.apib
538 lines (452 loc) · 23.8 KB
/
apiary.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
FORMAT: 1A
HOST: http://api.superdesk.org/v1/
# Superdesk Content API
The Superdesk Content API aims to empower news organizations using Superdesk to open
up their content to a broad community of innovative developers and encourage the
development of a diversity of news applications to engage readers wherever they are.
# Overview
The Superdesk Content API focuses on delivering news content. There are no
endpoints for fetching other resources such as users, desks or workflow activity.
You also cannot perform management operations to, for example, update or remove
news content.
API requests to retrieve news text items and media assets can be made through:
```
https://<your.subdomain>/v1/
```
All requests must be made over __https__. All data is sent and received in JSON.
# Current Version
We are currently developing the __Superdesk Content API v1__ version, the release
date is yet to be announced.
When working with the __Superdesk Content API__, you must explicitly request the
version of the API you want to use via URL, as in the following request:
```
https://api.superdesk.org/v1/items
```
# Content Model
Content in Superdesk is organized following the __News Architecture__ schema defined as
part of the [NewsML-G2](https://iptc.org/standards/newsml-g2/) standard developed by
the [IPTC](https://iptc.org/) for exchanging news and news management.
The Superdesk Content API delivers __news items__ and __packages__. A __News Item__
represents individual general news where the content can be textual, photos, graphics,
audio and video. A __Package__ is a structured bundle of __news items__.
# Response Format
All news content is delivered as JSON data. Images, audio clips, videos and other media
assets are delivered as files.
News content retrieved from the Content API is modeled using [ninjs](http://dev.iptc.org/ninjs)
(News in JSON). ninjs is an effort by the IPTC to standardize the representation of
news in JSON and it is designed to be used alongside other IPTC formats, including
NewsML-G2.
# HTTP Verbs
| Action | Verb | Description |
| --------- | :-------: | -------------------------------------------------: |
| Create | POST | Used for creating resources |
| Create | PUT | Used for replacing resources or collections |
| Replace | PUT | |
| Read | GET, HEAD | Used for retrieving resources |
| Update | PATCH | Used for updating resources with partial JSON data |
| Delete | DELETE | Used for deleting resources |
# Status Codes
Whenever something goes wrong with an API request, the server produces an error.
The error message contains an appropriate HTTP status code in the header and a
JSON response in the body.
| HTTP Status Code | Error Code | Description |
| ------------------- | :----------------: | -----------------------------------------------------------: |
| 400 | BadRequest | The request is malformed or a required parameter is missing. |
| 401 | Unauthorized | The authorization token is not valid. |
| 403 | Forbidden | |
| 404 | NotFound | The requested resource/endpoint can not be found. |
| 412 | PreconditionFailed | |
| 500 | InternalError | Something has gone wrong on our end. |
# Authentication
All requests must be authenticated using auth token from superdesk via `Authorization` header:
```
Authorization: Token <token-from-superdesk>
```
# SDK Libraries
SDKs are simply wrappers around the RESTful API to provide an added level of convenience
for developers. If you are planning to write an application that handles Superdesk content,
the SDK is the way to go to interact with the Content API.
## PHP
https://github.com/superdesk/contentapi-sdk-php
```
git clone [email protected]:superdesk/contentapi-sdk-php.git
```
If you can't find an SDK for your language of choice, you can help us building it by
yourself and contributing it to the Superdesk community. We are planning to work on
new SDKs and this is the space to watch in order to know about it.
# API Updates
To learn about future enhancements to the Content API and new versions of it, keep an
eye on this space. We will make sure you are properly informed on any changes made.
# Support
The Superdesk [development forum](https://forum.sourcefabric.org/categories/superdesk-dev)
is the best place for questions or to speak to other developers working with the
Content API.
For more information to stay up to date you can read our [developer blog](http://www.superdesk.org/en/site/news/?filter=Blog).
# Group API Resources
## Root Endpoint [/]
### Fetch all available resources [GET]
+ Headers
Authorization: OAuth2 a1hso5qapmhM0CozqBUyAjvrpISkdl
+ Response 200 (application/json)
{
"_links": {
"child": [
{
"href": "items",
"title": "items"
},
{
"href": "packages",
"title": "packages"
}
]
}
}
# Group Content Items
In Superdesk, a News Item is a generic container for any type of news content.
Photos, text, audio, video and graphics are all represented as News Items.
## Text News Item [/items/{_id}]
### Fetch a single Text News Item [GET]
This method is used to retrieve a particular item as a NewsML-G2 News Item
document in its ninjs (News in JSON) representation. To invoke this method, you
must know the item Id of the News Item you want to retrieve.
+ Headers
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MDk3ODkyNDEsInN1YiI6IjU4MTg3MTM3M2I4MGExMzg5MzFkNGQyYyJ9.kgehF33i5Zvbe6B_bDb8TYWT9oLWKJuFXOpQbInpExI
+ Parameters
+ _id (required, string, `1`) ... Identifier of the News Item you want to retrieve.
+ Response 200 (application/json)
{
"_links": {
"parent": {"href": "/", "title": "home"},
"collection": {"href": "items", "title": "items"},
"self": {"href": "items/tag:example.com,0000:newsml_BRE9A605", "title": "Item"}
},
"uri" : "http://site.com/items/tag:example.com,0000:newsml_BRE9A605",
"type" : "text",
"profile" : "text-html",
"versioncreated" : "2015-01-11T12:42:00Z",
"version": 1,
"copyrightnotice" : "Copyright 2015 News Agency, site.com - all rights reserved.",
"language" : "en",
"person" : [{
"name" : "John Doe",
"rel" : "about",
"scheme" : "http://site.com/scheme/",
"code" : "0hzcydt"
}],
"place" : [
{"name" : "Paris", "rel" : "mentions"},
{"name" : "France", "rel" : "mentions", "code" : "fr"}
],
"organisation" : [{
"name" : "Organisation",
"rel" : "mentions"
}],
"byline" : "John Doe",
"located" : "Paris, France",
"headline" : "Today's News",
"body_text" : "Lorem ipsum",
"body_html" : "<p>Lorem ipsum</p>"
}
## Picture News Item [/items/{_id}]
### Fetch a single Picture News Item [GET]
This method is used to retrieve a particular item as a NewsML-G2 News Item
document in its ninjs (News in JSON) representation. To invoke this method, you
must know the item Id of the News Item you want to retrieve.
+ Headers
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MDk3ODkyNDEsInN1YiI6IjU4MTg3MTM3M2I4MGExMzg5MzFkNGQyYyJ9.kgehF33i5Zvbe6B_bDb8TYWT9oLWKJuFXOpQbInpExI
+ Parameters
+ _id (required, string, `1`) ... Identifier of the News Item you want to retrieve.
+ Response 200 (application/json)
{
"_links": {
"parent": {"href": "/", "title": "home"},
"collection": {"href": "items", "title": "items"},
"self": {"href": "items/tag:example.com,0000:newsml_BRE9A605", "title": "Item"}
},
"uri" : "http://site.com/items/tag:example.com,0000:newsml_BRE9A605",
"type" : "picture",
"versioncreated" : "2015-01-11T12:42:00Z",
"byline" : "John Doe",
"headline" : "Today's Picture",
"description_text": "Lorem ipsum",
"description_xhtml": "<p>Lorem ipsum</p>",
"renditions" : {
"main" : {
"href" : "http://site.com/55f74d51cf0d605d5ce97a87.jpg",
"mimetype": "image/jpg",
"title" : "Large",
"height" : 256,
"width" : 512
},
"small" : {
"href" : "http://site.com/55f74d51cf0d605d5ce97a88.jpg",
"mimetype": "image/jpg",
"title" : "Thumbnail",
"height" : 32,
"width" : 32
}
}
}
## News Item Collection [/items?where={where}&start_date={start_date}&end_date={end_date}&include_fields={include_fields}&exclude_fields={exclude_fields}]
### List News Items [GET]
This method is used to retrieve a list of News Items.
+ The method will return a maximum of 200 items.
+ The items retrieved by this method will be sorted in reverse chronological
order (i.e., newest items first).
+ Headers
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MDk3ODkyNDEsInN1YiI6IjU4MTg3MTM3M2I4MGExMzg5MzFkNGQyYyJ9.kgehF33i5Zvbe6B_bDb8TYWT9oLWKJuFXOpQbInpExI
+ Parameters
+ where (optional, object) ... Filter.
+ start_date (optional, date) ... The start of the date range for the news
items to be retrieved. If no start date is specified, the news items
returned will be limited to the last 24 hours.
+ end_date (optional, date) ... The end of the date range for the news items
to be retrieved. If no end date is specified, the assumed end date will be
the current time.
+ include_fields (optional, list) ... The list of fields associated with content to
be retrieved. Default value: All available fields will be retrieved.
+ exclude_fields (optional, list) ... The list of fields associated with content which
should not be retrieved. Can not be used together with include_fields.
+ Response 200 (application/json)
{
"_meta": {
"page": 4, "total": 4, "max_results": 25
},
"_links": {
"self": {"title": "items", "href": "items?start_date=2014-01-01"},
"parent": {"title": "home", "href": "/"}
},
"_items": [
{
"_links": {
"parent": {"href": "/", "title": "home"},
"collection": {"href": "items", "title": "items"},
"self": {"href": "items/tag:example.com,0000:newsml_BRE9A605", "title": "Item"}
},
"uri": "http://site.com/items/tag:example.com,0000:newsml_BRE9A605",
"type": "text",
"version": 1,
"versioncreated": "2014-12-11T14:01:27+0000"
"headline": "Why failure isn't a dirty word",
"body_html": "<p>When JK Rowling delivered the 2008 Harvard commencement speech about failure, her audience consisted of hundreds of students, their families and the university’s faculty. But the impact of her words that day have since reached far wider.</p>",
"description_text": "text item"
}, {
"_links": {
"parent": {"href": "/", "title": "home"},
"collection": {"href": "items", "title": "items"},
"self": {"href": "items/tag:example.com,0000:newsml_BRE9A606", "title": "Item"}
},
"uri": "http://site.com/items/tag:example.com,0000:newsml_BRE9A606",
"type": "picture",
"version": 1,
"versioncreated": "2014-12-11T14:01:27+0000"
"mimetype": "image/jpeg",
"description_text": "picture item - also applicable to audio/video",
"renditions": {
"original": {
"href": "http://farm4.staticflickr.com/3665/9203816834_9f62964627_o_d.jpg",
"mimetype": "image/jpeg",
"width": 5198,
"height": 3462
}
}
}, {
"_links": {
"parent": {"href": "/", "title": "home"},
"collection": {"href": "items", "title": "items"},
"self": {"href": "items/tag:example.com,0000:newsml_BRE9A607", "title": "Item"}
},
"uri": "http://site.com/items/tag:example.com,0000:newsml_BRE9A607",
"type": "text",
"version": 1,
"versioncreated": "2014-12-11T14:01:27+0000"
"headline": "The fat-burning and energy-producing gyms",
"body_html": "<p>Professor Mawby feels that experiments like that at Cadbury House have a primary benefit is that they are making people aware. Through active engagement members are forced to acknowledge the physical value of energy and the cost of expanse of its wastage. </p>",
"description_text": "text item"
}, {
"_links": {
"parent": {"href": "/", "title": "home"},
"collection": {"href": "items", "title": "items"},
"self": {"href": "items/tag:example.com,0000:newsml_BRE9A608", "title": "Item"}
},
"uri": "http://site.com/items/tag:example.com,0000:newsml_BRE9A608",
"type": "text",
"version": 1,
"versioncreated": "2014-12-11T14:01:27+0000"
"headline": "The best pranks in children's books",
"body_html": "<p><strong>Mac:</strong> OK, fifth! Thanks, Henry. It’s exciting to be sharing these recommendations in The Guardian, with our UK readers. When I lived in London, I read The Guardian every day. Also, like some rappers, I demand to be paid only in British pounds. </p>",
"description_text": "text item"
}
]
}
# Group Content Packages
Package Items contain grouped references to multiple News Items.
## Package [/packages/{_id}]
### Fetch a single Package Item [GET]
The item method is used to retrieve a particular NewsML-G2 Package Item in
its ninjs (News in JSON) representation.
+ Headers
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MDk3ODkyNDEsInN1YiI6IjU4MTg3MTM3M2I4MGExMzg5MzFkNGQyYyJ9.kgehF33i5Zvbe6B_bDb8TYWT9oLWKJuFXOpQbInpExI
+ Parameters
- _id (string, `1`) ... Package Identifier.
+ Response 200 (application/json)
{
"_links": {
"collection": {"href": "packages", "title": "packages"},
"parent": {"href": "/", "title": "home"},
"self": {
"href": "packages/urn:newsml:localhost:2014-12-11T15:20:18.510755:65b31275-0513-4ee5-9879-1ef9fae5fa33",
"title": "Package"
}
},
"uri" : "http://site.com/packages/urn:newsml:localhost:2014-12-11T15:20:18.510755:65b31275-0513-4ee5-9879-1ef9fae5fa33",
"language": "en",
"pubstatus": "usable",
"type": "composite",
"version": 1,
"versioncreated": "2014-12-11T14:01:27+0000"
"slugline": "MARKETS-HONGKONG-STOCKS/CLOSE (URGENT)",
"headline": "Hong Kong shares end lower on profit-taking, China slump",
"description_text": "MARKETS-HONGKONG-STOCKS/CLOSE (URGENT):Hong Kong shares end lower on profit-taking, China slump",
"associations": {
"main": {
"uri" : "http://site.com/items/tag:reuters.com,0000:newsml_ZZN2NBZ00",
"type": "text",
"versioncreated": "2015-07-18T16:34:00Z",
"version": 1,
"located": "Hong Kong, China",
"slugline": "MARKETS-HONGKONG-STOCKS/CLOSE (URGENT)",
"headline": "Hong Kong shares end lower on profit-taking, China slump",
"body_html": "<p>Lorem ipsum</p>"
},
"picture": {
"uri" : "http://site.com/items/tag:example.com,0000:newsml_BRE9A607",
"type" : "picture",
"versioncreated" : "2015-07-18T16:34:00Z",
"copyrightnotice" : "Copyright 2015 News Agency, site.com - all rights reserved.",
"place" : [
{"name" : "Paris", "rel" : "mentions"},
{"name" : "France", "rel" : "mentions", "code" : "fr"}
],
"organisation" : [{
"name" : "Organisation",
"rel" : "mentions"
}],
"byline" : "John Doe",
"headline" : "Lorem Ipsum",
"description_text": "Lorem ipsum",
"description_xhtml": "<p>Lorem ipsum</p>",
"renditions" : {
"large" : {
"href" : "http://site.com/large-picture.jpg",
"mimetype": "image/jpg",
"title" : "Large Picture",
"height" : 256,
"width" : 512
},
"thumbnail" : {
"href" : "http://site.com/thumbnail-picture.jpg",
"mimetype": "image/jpg",
"title" : "Thumbnail Picture",
"height" : 32,
"width" : 64
}
}
}
}
}
## Package Collection [/packages?where={where}&start_date={start_date}&end_date={end_date}&include_fields={include_fields}&exclude_fields={exclude_fields}]
### List Package Items [GET]
The packages method is used to obtain a list of package items.
+ Headers
Authorization: Token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MDk3ODkyNDEsInN1YiI6IjU4MTg3MTM3M2I4MGExMzg5MzFkNGQyYyJ9.kgehF33i5Zvbe6B_bDb8TYWT9oLWKJuFXOpQbInpExI
+ Parameters
+ where (optional, object) ... Filter.
+ start_date (optional, date) ... The start of the date range for the news
items to be retrieved. If no start date is specified, the news items
returned will be limited to the last 24 hours.
+ end_date (optional, date) ... The end of the date range for the news items
to be retrieved. If no end date is specified, the assumed end date will be
the current time.
+ include_fields (optional, list) ... The list of fields associated with content to
be retrieved. Default value: All available fields will be retrieved.
+ exclude_fields (optional, list) ... The list of fields associated with content which
should not be retrieved. Can not be used together with include_fields.
+ Response 200 (application/json)
{
"_meta": {
"page": 1, "total": 1, "max_results": 25
},
"_links": {
"self": {"title": "packages", "href": "packages?start_date=2014-01-01"},
"parent": {"title": "home", "href": "/"}
},
"_items": [
{
"_links": {
"collection": {"href": "packages", "title": "packages"},
"parent": {"href": "/", "title": "home"},
"self": {
"href": "packages/urn:newsml:localhost:2014-12-11T15:20:18.510755:65b31275-0513-4ee5-9879-1ef9fae5fa33",
"title": "Package"
}
},
"uri" : "http://site.com/packages/urn:newsml:localhost:2014-12-11T15:20:18.510755:65b31275-0513-4ee5-9879-1ef9fae5fa33",
"language": "en",
"pubstatus": "usable",
"type": "composite",
"version": 1,
"versioncreated": "2014-12-11T14:01:27+0000"
"slugline": "MARKETS-HONGKONG-STOCKS/CLOSE (URGENT)",
"headline": "Hong Kong shares end lower on profit-taking, China slump",
"description_text": "MARKETS-HONGKONG-STOCKS/CLOSE (URGENT):Hong Kong shares end lower on profit-taking, China slump",
"associations": {
"main": {
"uri" : "http://site.com/items/tag:reuters.com,0000:newsml_ZZN2NBZ00",
"type": "text",
"versioncreated": "2015-07-18T16:34:00Z",
"version": 1,
"located": "Hong Kong, China",
"slugline": "MARKETS-HONGKONG-STOCKS/CLOSE (URGENT)",
"headline": "Hong Kong shares end lower on profit-taking, China slump",
"body_html": "<p>Lorem ipsum</p>"
},
"picture": {
"uri" : "http://site.com/items/tag:example.com,0000:newsml_BRE9A607",
"type" : "picture",
"versioncreated" : "2015-07-18T16:34:00Z",
"copyrightnotice" : "Copyright 2015 News Agency, site.com - all rights reserved.",
"place" : [
{"name" : "Paris", "rel" : "mentions"},
{"name" : "France", "rel" : "mentions", "code" : "fr"}
],
"organisation" : [{
"name" : "Organisation",
"rel" : "mentions"
}],
"byline" : "John Doe",
"headline" : "Lorem Ipsum",
"description_text": "Lorem ipsum",
"description_xhtml": "<p>Lorem ipsum</p>",
"renditions" : {
"large" : {
"href" : "http://site.com/large-picture.jpg",
"mimetype": "image/jpg",
"title" : "Large Picture",
"height" : 256,
"width" : 512
},
"thumbnail" : {
"href" : "http://site.com/thumbnail-picture.jpg",
"mimetype": "image/jpg",
"title" : "Thumbnail Picture",
"height" : 32,
"width" : 64
}
}
}
}
}
]
}