Large portions of the knowledge of the Hans Christian Andersen Center have become available as REST web services.
Web services are not suited for normal web browsing, but for developers of other systems, who can retrieve the data and display them as they please.
Indexes
See how to retrieve single items below.
- Letters: https://andersen.sdu.dk/service/letters
- People: https://andersen.sdu.dk/service/people
- Bibliography: https://andersen.sdu.dk/service/biblio
The websites
- Letters: https://andersen.sdu.dk/brevbase
- People: https://andersen.sdu.dk/brevbase/person.html
- Bibliography: https://andersen.sdu.dk/forskning/bib/
Letters to/from a person and/or a date or period of time
You can retrieve a list of letters to and from a person by requesting the person ID according to the pattern /letters/person/{person ID}
, e.g. https://andersen.sdu.dk/service/letters/person/2.
Letters may be listed after date according to the pattern /letters/date/{YYYY[-MM[-DD]]}
, i.e. /letters/date/
followed by a year, year-month or year-month-day. Examples:
- Letters from 1823: https://andersen.sdu.dk/service/letters/date/1823
- Letters from December 1823: https://andersen.sdu.dk/service/letters/date/1823-12
- Letters from December 1, 1823: https://andersen.sdu.dk/service/letters/date/1823-12-01
Person and date/period may be combined according to the pattern /letters/person/{person ID}/date/{YYYY[-MM[-DD]]}
, e.g. all letters to and from Charles Dickens in 1847: https://andersen.sdu.dk/service/letters/person/265/date/1847.
Letters with unknown or uncertain date
The letter database contains letters with unknown or uncertain dates. The uncertainty can apply to either year, month, or day. Letters from 1823 with uncertain month are contained in the display of letters from 1823 (first link above), but may also be displayed separately, if you specify 00
for the month:
- Letters with unknown month from 1823: https://andersen.sdu.dk/service/letters/date/1823-00
- Letters with unknown year: https://andersen.sdu.dk/service/letters/date/0000
- Letters from September, year unknown: https://andersen.sdu.dk/service/letters/date/0000-09
Notice: incomplete information
Some letters have multiple senders or receivers. That is ignored in this web service. Fetch the individual letter in order to get complete information.
Publications (bibliography) from a date or period and/or in a certain language
Publications from a certain time can be retrieved following the pattern /biblio/date/{YYYY[-MM[-DD]]}
, i.e. /biblio/date/
followed by year, year-month or year-month-day. Examples:
- Published 1822: https://andersen.sdu.dk/service/biblio/date/1822
- Published April 1835: https://andersen.sdu.dk/service/biblio/date/1835-04
- Published April 2, 1875: https://andersen.sdu.dk/service/biblio/date/1875-04-02
Publications in a certain language can be retrieved following the pattern /biblio/language/{language code}
, i.e. /biblio/language/
followed by a three-letter language code (ISO 639-2/B). For example all literature in Polish from our database: https://andersen.sdu.dk/service/biblio/language/pol.
Languages and language codes
German ('ger') includes Low German ('nds').
This list contains all possible languages in our database, not nescessarily languages with which we have linked any literature.
Language | Language code |
---|---|
Afrikaans | afr |
Albanian | alb |
Arabic | ara |
Armenian | hye |
Bosnian | bos |
Bulgarian | bul |
Catalan | cat |
Chinese | chi |
Croatian | hrv |
Czech | cze |
Danish | dan |
Dutch | dut |
English | eng |
Esperanto | epo |
Estonian | est |
Faroese | fao |
Finnish | fin |
French | fre |
Frisian | fry |
Galician | glg |
German | ger |
Greek | gre |
Greenlandic | kal |
Hebrew | heb |
Hindi | hin |
Hungarian | hun |
Icelandic | ice |
Indonesian | ind |
Interlingua | ina |
Irish | gle |
Italian | ita |
Japanese | jpn |
Latvian | lav |
Lithuanian | lit |
Low German | nds |
Maltese | mlt |
Moldavian | mol |
Norwegian | nor |
Persian | fas |
Polish | pol |
Portuguese | por |
Romanian | ron |
Russian | rus |
Serbian | srp |
Slovak | slo |
Slovene | slv |
Somali | som |
Spanish | spa |
Swedish | swe |
Tatar Language | tat |
Turkish | tur |
Ukrainian | ukr |
Urdu | urd |
Vietnamese | vie |
Volapük | vol |
Yiddish | yid |
Zulu | zul |
Language and date/period may be combined using the pattern /biblio/date/{YYYY[-MM[-DD]]}/language/{language code}
, e.g. all publications in English from the year 1847: https://andersen.sdu.dk/service/biblio/date/1847/language/eng.
Single items
Single items, e.g. a letter, can be fetched according to these patterns:
- Letter: /service/letters/{letter ID}
e.g. https://andersen.sdu.dk/service/letters/246 - Person: /service/people/{person ID}
e.g. https://andersen.sdu.dk/service/people/1 - Bibliographical description: /service/biblio/{bibliografi-ID}
e.g. https://andersen.sdu.dk/service/biblio/1
Technique
Request method
The only working request method is GET
, i.e. you can get, but not change data.
Formats and parameters
The service returns JSON, or JSONP, if you add '?callback={callback-identifier}'
, e.g. https://andersen.sdu.dk/service/biblio/1?callback=return. The callback-identifier only works with one of the following values (otherwise you will get JSON):
'break', 'do', 'instanceof', 'typeof', 'case',
'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue',
'for', 'switch', 'while', 'debugger', 'function', 'this', 'with',
'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum',
'extends', 'super', 'const', 'export', 'import', 'implements', 'let',
'private', 'public', 'yield', 'interface', 'package', 'protected',
'static', 'null', 'true', 'false'
Some data contain HTML entities for special characters, e.g. this bibliographical description with greek letters: https://andersen.sdu.dk/service/biblio/17779. You can add htmlencode=false
to the request and get the characters straight: https://andersen.sdu.dk/service/biblio/17779?htmlencode=false.
htmlencode=false
combined with JSONP: https://andersen.sdu.dk/service/biblio/17779?callback=return&htmlencode=false.
htmlencode=false
is relevant for letters and the bibliography, i.e. /letters/{brev-ID}
and /biblio/{bibliografi-ID}
.
Standards
The language codes are according to ISO 639-2/B, with the addition of 'hca'; Danish at Hans Christian Andersen's time.
How?
We recommend inspecting the structure of the web services with e.g. apps or addons for Google Chrome or RESTClient for Firefox.
You can retrieve and parse the JSON code from the web services using several programming languages, among others PHP, C# and JQuery / Javascript.
Simple code example in PHP
# The service URI. Letters to and from Charles Dickens: $letters_uri = "https://andersen.sdu.dk/service/letters/person/265"; # Initializes a new session and return a cURL handle $curl_handle = curl_init($letters_uri); # Set CURL options: return as string curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); # Open CURL session: $json_letters = curl_exec($curl_handle); # Now that we've got the JSON in $letters, we can close the session and save server resources: curl_close($curl_handle); # Decode the JSON. True means into an associative array: $letters = json_decode($json_letters, true); # Getting the number of letters. Minus 2, because two rows are taken by meta information. The letters have numeric keys, starting at 0. $number_of_letters = count($letters); # Printing number of letters echo "<p>There are " . $number_of_letters . " letters from and to Charles Dickens in the HCA-Center database.</p>"; # create a table. Feel free to create neater HTML: $table = ""; $tablerows = ""; /** * Available array keys and example values: * * "Date": "1868-04-20", * "ID": "23360", * "URI": "https://andersen.sdu.dk/service/letters/23360", * "Sender name": "H.C. Andersen", * "Receiver name": "Georg Brandes", * "Sender ID": "1", * "Receiver ID": "139", * "Sender URI": "https://andersen.sdu.dk/service/people/1", * "Receiver URI": "https://andersen.sdu.dk/service/people/139" */ # looping through the array of letter data for($x = 0; $x < $number_of_letters; $x++) { $tablerows .= "<tr>"; $tablerows .= "<td><a href=\"https://andersen.sdu.dk/brevbase/brev.html?bid=" . $letters[$x]["ID"] . "\">" . $letters[$x]["Date"] . "</a></td>"; $tablerows .= "<td>" . $letters[$x]["Sender name"] . "</td>"; $tablerows .= "<td>" . $letters[$x]["Receiver name"] . "</td>"; $tablerows .= "</tr>"; } $table = "<table class=\"sortTabel\"> <tr><th>Date</th><th>Sender</th><th>Receiver</th></tr> " . $tablerows . "</table>"; echo $table; ?>