Ruben Verborgh, Ghent University – imec
Except where otherwise noted, the content of these slides is licensed under a Creative Commons Attribution 4.0 International License.
The server does not know any client’s previous state.
Clients might jump to unpermitted states by “guessing”.
REST introduces 4 uniform interface constraints:
An urban architect does not control individual buildings.
Cache-Control: max-age=3600
ETag: UniqueHash456
The Web supports all 4 constraints:
Accept
,Content-Type
.
Accept: application/json,text/html;q=0.6
Content-Type
header
details the media type.
{ "url": "https://perdu.com/" }
is not a link.
application/json
media typeapplication/hal+json
media typeContent-Type: application/hal+json
.
When I say hypertext,
Roy Fielding
I mean the simultaneous presentation of information and controls such that the information becomes the affordance through which the user (or automaton) obtains choices and selects actions.
https://example.org/songs/showDetails.php
https://example.org/songs/3563642
https://example.org/songs/3563642 results in HTML.
https://api.example.org/getObjectJson.php?id=183113 results in JSON.
https://example.org/songs/3563642 results in HTML.
And results in JSON.
And results in XML.
HTTP/1.1 5027 Incomplete
Custom-Server-Id: song.1.2
Content-Type:
application/json
HTTP/1.1 200 OK
Server: Song-Server 1.2
Content-Type:
application/vnd.acme.songs
Cache-Control: max-age=3600
{
"title": "Baba O’Riley",
"artist": {
"id": 5521
}
}
{
"title": "Baba O’Riley",
"artist": {
"id": "https://example.org/
artists/5521"
}
}
https://google.com/
https://google.com/documentation.html
To use this site,
enter your search term as follows:
https://www.google.com/search?q=search+term
In the above, search+term is
the URL-encoded version of your search term.
number of Web APIs
indexed in ProgrammableWeb
Which one would be easier?
curl -H "Accept: application/json" \
https://www.europeana.eu/portal/en/record/9200229/BibliographicResource_3000135601313
All of that wasn’t necessary for the website,
even though it contains the exact same information.
https://europeana.eu/api/v2/record/9200229/BibliographicResource_3000135601313.json?wskey=xxxxxxxxx
{
"apikey": "xxxxxxxxx",
"action": "--deprecated--",
"success": true,
"statsDuration": 110,
"requestNumber": 999,
"object": {
"type": "IMAGE",
"edmDatasetName": [ "9200229_Ag_EU_TEL_a1112_LibGent" ],
"title": [ "Belfort, Botermarkt, Gent klokkentoren (1853)" ],
"about": "/9200229/BibliographicResource_3000135601313",
"europeanaAggregation": {
"about": "/aggregation/europeana/9200229/BibliographicResource_3000135601313",
"aggregatedCHO": "/item/9200229/BibliographicResource_3000135601313",
"edmLandingPage": "https://europeana.eu/portal/record/9200229/BibliographicResource_3000135601313.html",
"edmCountry": { "def": [ "belgium" ] },
"edmLanguage": { "def": [ "mul" ] },
"edmRights": {
"def": [ "https://creativecommons.org/licenses/by-sa/4.0/" ]
},
"edmPreview": "https://europeanastatic.eu/api/image?uri=http%3A%2F%2Fadore.ugent.be%2FOpenURL%2Fresolve%3Fsvc_id%3Dmedium%26url_ver%3DZ39.88-2004%26rft_id%3Darchive.ugent.be%3A3107D15A-BB55-11E3-8B3D-86C4D43445F2%3A1&size=LARGE&type=IMAGE"
},
"proxies": [
{
"about": "/proxy/provider/9200229/BibliographicResource_3000135601313",
"dcDescription": {
"def": [
"Stempel op keerzijde afbeelding: Copyright A.C.L.",
"Handgeschreven notitie op keerzijde afbeelding: 102308 B"
]
},
"dcFormat": { "en": [ "Printed" ] },
"dcIdentifier": { "def": [ "002075264" ] },
"dcRights": {
"def": [
"Reproductierecht Universiteitsbibliotheek Gent",
"CC BY-SA (4.0)"
]
},
"dcTitle": {
"def": [ "Belfort, Botermarkt, Gent klokkentoren (1853)" ]
},
"dcType": { "en": [ "Serial" ] },
"dctermsExtent": {
"def": [ "1 fotografische druk : : zwart/wit." ]
},
"dctermsIsPartOf": {
"def": [ "http://data.theeuropeanlibrary.org/Collection/a1112" ]
},
"dctermsIssued": {
"def": [
"1875? - 1930?",
"[eind 19e-begin 20e eeuw]."
]
},
"dctermsSpatial": {
"def": [ "België, Vlaanderen, Oost-Vlaanderen, Gent (9000), Gent (9000)" ]
},
"proxyIn": [
"/aggregation/provider/9200229/BibliographicResource_3000135601313"
],
"proxyFor": "/item/9200229/BibliographicResource_3000135601313",
"edmType": "IMAGE",
"europeanaProxy": false
},
{
"about": "/proxy/europeana/9200229/BibliographicResource_3000135601313",
"proxyIn": [
"/aggregation/europeana/9200229/BibliographicResource_3000135601313"
],
"proxyFor": "/item/9200229/BibliographicResource_3000135601313",
"edmType": "IMAGE",
"europeanaProxy": true
}
],
"aggregations": [
{
"about": "/aggregation/provider/9200229/BibliographicResource_3000135601313",
"edmDataProvider": {
"def": [ "Ghent University Library" ]
},
"edmIsShownBy": "https://adore.ugent.be/OpenURL/app?type=carousel&id=archive.ugent.be:3107D15A-BB55-11E3-8B3D-86C4D43445F2",
"edmObject": "https://adore.ugent.be/OpenURL/resolve?svc_id=medium&url_ver=Z39.88-2004&rft_id=archive.ugent.be:3107D15A-BB55-11E3-8B3D-86C4D43445F2:1",
"edmProvider": {
"en": [ "The European Library" ]
},
"edmRights": {
"def": [ "https://creativecommons.org/licenses/by-sa/4.0/" ]
},
"aggregatedCHO": "/item/9200229/BibliographicResource_3000135601313",
"webResources": [
{
"webResourceEdmRights": {
"def": [ "https://creativecommons.org/licenses/by-sa/4.0/" ]
},
"about": "https://adore.ugent.be/OpenURL/app?type=carousel&id=archive.ugent.be:3107D15A-BB55-11E3-8B3D-86C4D43445F2",
"textAttributionSnippet": "Belfort, Botermarkt, Gent klokkentoren (1853) - https://europeana.eu/portal/record/9200229/BibliographicResource_3000135601313.html. Ghent University Library. CC BY-SA - https://creativecommons.org/licenses/by-sa/4.0/",
"htmlAttributionSnippet": "<span about='https://data.europeana.eu/item/9200229/BibliographicResource_3000135601313'><a href='https://europeana.eu/portal/record/9200229/BibliographicResource_3000135601313.html'><span property='dc:title'>Belfort, Botermarkt, Gent klokkentoren (1853)</span></a>. Ghent University Library. <a href='https://creativecommons.org/licenses/by-sa/4.0/' rel='xhv:license https://www.europeana.eu/schemas/edm/rights'>CC BY-SA</a><span rel='cc:useGuidelines' resource='https://www.europeana.eu/rights/pd-usage-guide/'>.</span></span>"
},
{
"webResourceEdmRights": {
"def": [ "https://creativecommons.org/licenses/by-sa/4.0/" ]
},
"about": "https://adore.ugent.be/OpenURL/resolve?svc_id=medium&url_ver=Z39.88-2004&rft_id=archive.ugent.be:3107D15A-BB55-11E3-8B3D-86C4D43445F2:1",
"textAttributionSnippet": "Belfort, Botermarkt, Gent klokkentoren (1853) - https://europeana.eu/portal/record/9200229/BibliographicResource_3000135601313.html. Ghent University Library. CC BY-SA - https://creativecommons.org/licenses/by-sa/4.0/",
"htmlAttributionSnippet": "<span about='https://data.europeana.eu/item/9200229/BibliographicResource_3000135601313'><a href='https://europeana.eu/portal/record/9200229/BibliographicResource_3000135601313.html'><span property='dc:title'>Belfort, Botermarkt, Gent klokkentoren (1853)</span></a>. Ghent University Library. <a href='https://creativecommons.org/licenses/by-sa/4.0/' rel='xhv:license https://www.europeana.eu/schemas/edm/rights'>CC BY-SA</a><span rel='cc:useGuidelines' resource='https://www.europeana.eu/rights/pd-usage-guide/'>.</span></span>"
}
],
"edmPreviewNoDistribute": false
}
],
"providedCHOs": [
{
"about": "/item/9200229/BibliographicResource_3000135601313"
}
],
"europeanaCompleteness": 7,
"europeanaCollectionName": [ "9200229_Ag_EU_TEL_a1112_LibGent" ],
"language": [ "mul" ],
"timestamp_created_epoch": 1442493422613,
"timestamp_update_epoch": 1455546713777,
"timestamp_created": "2015-09-17T12:37:02.613Z",
"timestamp_update": "2016-02-15T14:31:53.777Z"
}
}
Engineer for serendipity.
Roy Fielding
<request method="getSongDetails" id="22896"/>
<response status="success"/>
A SOAP message consists of 3 main XML elements.
The client sends such an XML document with HTTP POST
to a single specific URL that identifies the service.
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
</env:Header>
<env:Body>
<s:getSongDetails xmlns:m="http://example.org/song-service">
<s:id>22896</s:id>
</s:getSongDetails>
</env:Body>
</env:Envelope>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
</env:Header>
<env:Body>
<s:songDetails xmlns:m="http://example.org/song-service">
<s:title>Baba O’Riley</s:title>
<s:artistId>5521</s:artistId>
</s:songDetails>
</env:Body>
</env:Envelope>
POST
There exist 3 broad uses for descriptions.
Description formats support one or more of them.
application/json
application/hal+json
._links
key with named links.<form>
of RDF.
What the customer
thought they needed
How the project leader
understood it
How the programmer
wrote it
How the customer
was billed
What the customer
really needed
If a customer wants to make their website accessible
for automated clients, what do you propose?
If they ask for a Web API, what do you propose?
And—most importantly—what do you bill them for? 😉