API Use Cases

Project NemDigitaliser

Digitaliser.dk has an advanced, open API.

Documentation is .. sparse. The api methods are listed and briefly explained on the api’s site, but the overall architecture as well as its fundamental usage information is not described anywhere I can find.

First use case: I want to get the latest resources

Lo and behold, the api has a method for finding the latest stuff: /resources/latest/rss

But wait, that is the RSS feed. It appears this is some hardcoded thing, and I see no /resources/latest/json or anything else (the only documented qualifier is linkto= which I don’t know what does).

Speaking of JSON: As noted, the api ‘speaks’ JSON, by calling ?format=json (and jsonp). So default is XML, but adding this string gives you JSON.

Finding: The api has no simple way of getting the latest resources in XML/JSON, it appears.

Second use case: I want to get all resources of a certain kind

In Digitaliser.dk, content is ‘resources’. There are several kinds of resources (Generisk Ressource, Begrebsmodel, Informationsmodel, Software, Syntaks, Teknisk specifikation, and Datakilde). In this use case, I want to get all Datakilde (data source) resources.

The api has a resource search function: resources/search. Nice, search for resources about something (say, the Danish Parliament). So, maybe I can search for certain kinds of resources? The api doc says:

query={query}&
firstResult={firstResult}&
maxResults={maxResults}&
tags={tags}&
classificationChoices={classificationChoices}

Five options. Nice with tagability, but not what we need here. The tricky one here is classificationChoices. Surely that must be related to the resource categories? Or?

Looking up rest/classifications, we’re informed there are two classes: Datastandard and Teknisk standard. Ah, the classification is used to describe e-GIF standards.

Finding: The api has no simple way of showing found/all resources of a certain kind.

Third use case: I want to get the latest Datakilde resources

Obviously, this is the two use cases above combined.

One solution could be this:

Grab the RSS feed. Scrape it. List resource IDs. Lookup each ID and check if it is a Datakilde. Grab info and put in array. Loop array. Output.

Other ideas?

Updates
For the heck of it, I had a go at the solution described above. This is the result (code). Feel free to laugh at my coding skills (but it does the job).

Oh, I also made this version: New Datakilder.