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. 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:

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:

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: 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.

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: 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:

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;
?>

Output: