BeLawsHub APIv1 Documentation

purpose

This is a «single document application» which contains the API documentation for belaws.be and an application which makes it possible to test the documented code live against our servers, ideally this should become the first place a developer can check the status of the API. The purpose of this is to future proof the API against random failures, giving new and seasoned developers a heads up regarding the status of the API.

authors & copyright

Tim Esselens
Copyright 2011 - 2015 iRail working group of Open Knowledge Belgium vzw/asbl (AGPL).

bugreport & feedback

For suggestions, ideas and general feedback head over to our getsatisfied.com page. If on the other hand you want to put in some much appreciated ellbow grease and create a developer bugreport please add a github issue

links

Interactive API Documentation

GET /api/search.json

synopsis

$.ajax({
    type: "GET",
    url: "/api/search.json",
    data: { 
        q: "decreet onderwijs",
        hl: 1,
        lang: 'nl'
     },
    dataType: "jsonp",
    success: function(rows) { 
        $.each(rows,function(index,row) {
            log(index + ') ' + row.title);
            if(index >= 30) { last; }
        });
    },
    error: function() { alert('unable to fetch resouce'); }
});

description

Searches in the full text indexer

parameters

typeexamplecomment
qstringunique document identifier
hlbooleanhilight returned results
langnl | fr | delimit search to lang (not implemented yet)

result

The returned result (JSON) is an array of objects with title and docuid being the most important.

[
    {
        pubdate: "22-12-1851",
        docuid: "1851-12-16/01",
        title: "16 DECEMBER 1851. - HYPOTHEEKWET - BURGERLIJK WETBOEK BOEK III TITEL XVIII : Voorrechten en hypotheken. "
    },
    {
        pubdate: "10-01-1968",
        docuid: "1967-12-22/02", 
        title: "22 DECEMBER 1967. - Koninklijk besluit houdende algemeen reglement betreffende het rust- en overlevingspensioen der zelfstandigen. "
    }
]

With the hl flag set to true the titles will be marked with <b> tags. Note that the marking will be done using the Full Text Search engine of PostgreSQL which in turn means that a language sensitive match can be made. For example onderneming and ondernemingen will both be marked when searching for onderneming

bugs and shortcomings


GET /api/doc.json

synopsis

$.ajax({
    type: "GET",
    url: "/api/doc.json",
    data: { docuid: "1967-12-22/02", q: "reglement" },
    dataType: "jsonp",
    success: function(obj) {
        log('got document ['+obj.docuid+']'+
            ' with title "'+obj.title+'"');
    },
    error: function() { alert('unable to fetch resouce'); }
});

description

Retreives a single document

parameters

typeexamplecomment
docuidstringunique document identifier
qstringused to hilight the body
attrlist possible attributes: body title docuid pubdate plain pubid source pages effective pretty
langnl|fr|delimit search to lang (not implemented yet)

result

The returned result (JSON) is an object with body and docuid being the most important properties.

{
    source: null,
    body: "<HTML VERSION...",
    plain: "...",
    pretty: "<article>..."
    pubdate: "10-01-1968",
    pubid: "1967122203",
    docuid: "1967-12-22/02",
    title: "22 DECEMBER 1967. - Koninklijk besluit houdende algemeen reglement betreffende het rust- en overlevingspensioen der zelfstandigen. ",
    effective: "01-01-1968",
    pages: 235
}

bugs and shortcomings


GET /api/class/person.json

synopsis

$.ajax({
    type: "GET",
    url: "/api/class/person.json",
    data: { q: "arbeid" },
    dataType: "jsonp",
    success: function(obj) {
        $.each(obj,function(i,o) {
            log('got Person ['+o.name+']'+
                ' with count "'+o.count+'"');
        })
    },
    error: function() { alert('unable to fetch resouce'); }
});

description

Searches the db and returns docuids classified per person

parameters

typeexamplecomment
qstringused to hilight the body
langnl | fr | delimit search to lang (not implemented yet)

result

 [
    {
        docuids: [ "2009-12-15/10", "2010-02-10/07", ... ]
        count: "246"
        name: "J. MILQUET"
    },
    {
        docuids: [ ... ]
        count: "229"
        name: "L. ONKELINX"
    },
] 

bugs and shortcomings

Other Documentation

CHANGELOG

BeLaws webinterface changelog

commitnamedatemessage

BeLaws test page changelog

This is the page you are looking at (api.v1.html)
commitnamedatemessage

THANKS