DK | EN
Web services
H.C. Andersen-centret ved Syddansk Universitet. Hjemmesiden er en base for forskning, tekster og information om og af H.C. Andersen. Man kan finde materialer om (nøgleordene) eventyr, forfatter, litteratur, børnelitteratur, børnebøger, undervisning, studie, Victor Borge, HC Andersen, H. C. Andersen, liv, værk, tidstavle og biografi, citater, drømme, FAQ, oversættelse, bibliografi, anmeldelser, quiz, børnetegninger, 2005 og manuskripter
The Hans Christian Andersen Center

Web services

Skip over navigation and news

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.

The websites

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. http://www.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:

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: http://www.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:

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:

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: http://www.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.

LanguageLanguage code
Afrikaansafr
Albanianalb
Arabicara
Armenianhye
Bosnianbos
Bulgarianbul
Catalancat
Chinesechi
Croatianhrv
Czechcze
Danishdan
Dutchdut
Englisheng
Esperantoepo
Estonianest
Faroesefao
Finnishfin
Frenchfre
Frisianfry
Galicianglg
Germanger
Greekgre
Greenlandickal
Hebrewheb
Hindihin
Hungarianhun
Icelandicice
Indonesianind
Interlinguaina
Irishgle
Italianita
Japanesejpn
Latvianlav
Lithuanianlit
Low Germannds
Maltesemlt
Moldavianmol
Norwegiannor
Persianfas
Polishpol
Portuguesepor
Romanianron
Russianrus
Serbiansrp
Slovakslo
Sloveneslv
Somalisom
Spanishspa
Swedishswe
Tatar Languagetat
Turkishtur
Ukrainianukr
Urduurd
Vietnamesevie
Volapükvol
Yiddishyid
Zuluzul

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: http://www.andersen.sdu.dk/service/biblio/date/1847/language/eng.

Single items

Single items, e.g. a letter, can be fetched according to these patterns:

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. http://www.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: http://www.andersen.sdu.dk/service/biblio/17779. You can add htmlencode=false to the request and get the characters straight: http://www.andersen.sdu.dk/service/biblio/17779?htmlencode=false.

htmlencode=false combined with JSONP: http://www.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 = "http://www.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": "http://www.andersen.sdu.dk/service/letters/23360",
 * "Sender name": "H.C. Andersen",
 * "Receiver name": "Georg Brandes",
 * "Sender ID": "1",
 * "Receiver ID": "139",
 * "Sender URI": "http://www.andersen.sdu.dk/service/people/1",
 * "Receiver URI": "http://www.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=\"http://www.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;
?>

Output:

There are 40 letters from and to Charles Dickens in the HCA-Center database.

DateSenderReceiver
1847-03-30Charles DickensWilliam Jerdan
1847-07-13Charles DickensMarguerite Power
1847-07-14Charles DickensWilliam Jerdan
1847-07-30Charles DickensH.C. Andersen
1847-07-31Charles DickensH.C. Andersen
1847-07-31Charles DickensH.C. Andersen
1847-07-31H.C. AndersenCharles Dickens
1847-08-01Charles DickensH.C. Andersen
1847-08-29H.C. AndersenCharles Dickens
1847-08-30Charles DickensH.C. Andersen
1847-08-30Charles DickensH.C. Andersen
1847-12-06H.C. AndersenCharles Dickens
1848-01-00Charles DickensH.C. Andersen
1848-01-01H.C. AndersenCharles Dickens
1849-04-00H.C. AndersenCharles Dickens
1849-04-29H.C. AndersenCharles Dickens
1849-06-04Charles DickensH.C. Andersen
1850-07-16H.C. AndersenCharles Dickens
1851-05-00H.C. AndersenCharles Dickens
1851-07-05Charles DickensH.C. Andersen
1851-07-07H.C. AndersenCharles Dickens
1856-07-05Charles DickensH.C. Andersen
1856-12-15Charles DickensCharles de la Pryme
1857-03-00H.C. AndersenCharles Dickens
1857-04-03Charles DickensH.C. Andersen
1857-04-14H.C. AndersenCharles Dickens
1857-05-12Charles DickensH.C. Andersen
1857-05-12Charles DickensH.C. Andersen
1857-05-22Charles DickensJames White
1857-05-31Charles DickensRichard Bentley
1857-06-03Charles DickensAngela Georgine Burdett-Coutts
1857-06-10H.C. AndersenCharles Dickens
1857-07-10Charles DickensAngela Georgine Burdett-Coutts
1857-07-21Charles DickensWilliam Jerdan
1857-08-01H.C. AndersenCharles Dickens
1857-09-00H.C. AndersenCharles Dickens
1857-09-02Charles DickensH.C. Andersen
1857-09-29H.C. AndersenCharles Dickens
1858-06-00H.C. AndersenCharles Dickens
1862-04-23H.C. AndersenCharles Dickens

The dates in the example are printed as they are, i.e. compliant with the ISO 8601 standard. It is up to the users of the web service to modify the date format for your needs.

Other Hans Christian Andersen web services

Lars Bo Jensen April 2, 2013