How to use the City of Stockholm Open API

Postad av: Johannes Söderlund,

This post will briefly describe how developers can get information from the City of Stockholm’s Open API.

Introduction

All City Services is presented on the City of Stockholm’s website in an e-service called Compare Services.
Here you can find pre-schools, schools, home-services, nursing homes and such.

Each service unit has the following information:

Presentation page on www.stockholm.se for a pre-school.

servicetuype-1

You can also retrieve data on public places in the City of Stockholm in a similar way.

The addresses for the API’s are:
http://api.stockholm.se/ServiceGuideService/?apikey
http://api.stockholm.se/PlaceService/?apikey

How to use the API

  1. Data is retrieved via HTTP / GET and the format is XML or JSON.
  2. To retrieve data the API requires an API key. Create your key on http://api.stockholm.se
  3. Api-key / authentication
    For every HTTP / GET request use the parameter ‘apikey’ plus value.An “endpoint” is the last directory name before the last and final ”/”.Example:
    / Service Guide Service /
    Anything after the ”endpoint” is regarded as an ”identifier”.Examples with parameter:
    http://api.stockholm.se/ServiceGuideService/?apikey=yournotsosecretkeyvalue1234
  4. Listing / Segmentation
    Data can be accessed in different ways. Based on the results you can see how to further segment the results.

    The following method lists all possible liststings (aka ”starting endpoint”):
    http://api.stockholm.se/ServiceGuideService/?apikey=yournotsosecretkeyvalue1234

    This provides (among other things):
    <Lists>
    <List uri=”ServiceUnits”/>
    <List uri=”ServiceUnitTypes”/>
    <List uri=”ServiceUnitTypeGroups”/>
    <List uri=”GeographicalAreas”/>
    <List uri=”Files”/>
    </Lists>http://api.stockholm.se/ServiceGuideService/ServiceUnitTypes?apikey=yournotsosecretkeyvalue1234

    The url above will render the following result:
    <ServiceUnitTypeInfos>
    <ServiceUnitTypeInfo id=”9911eb71-854b-4033-9f90-00ab2a72d739″singularName=”Personlig assistans”/>
    <ServiceUnitTypeInfo id=”a4116a6a-af53-4672-b492-01d7adeae987″singularName=”Motionssp?r”/>
    <ServiceUnitTypeInfo id=”fd27590d-11ad-4811-9327-13e5a9fe9794″singularName=”Konsthall”/>
    <ServiceUnitTypeInfo id=”3a8dadd5-e10c-415c-8b37-1a25729afffa”singularName=”Familjedaghem”/>
    <ServiceUnitTypeInfosingularName=”Kolonitr?dg?rd”/>
    <ServiceUnitTypeInfo id=”930b3308-43e9-471f-b8f4-2bf4f135e30d”singularName=”Ledsagning”/>
    <ServiceUnitTypeInfo id=”c72b4fcc-3f50-4dc4-aac3-303c6797d430″singularName=”Hemtj?nst”/>
    <ServiceUnitTypeInfo id=”f1f37ab7-8f65-40fe-97cb-31676d1bab34″singularName=”Servicebostad”/>
    <ServiceUnitTypeInfo id=”4effe8e3-ef54-4f43-8d50-372a4495d435″singularName=”Servicehus”/>
    <ServiceUnitTypeInfosingularName=”Simhall”/>
    <!– more rows –>
    <ServiceUnitTypeInfo id=”fcc0db7f-065e-43f9-94f0-fb7c4467ffde”singularName=”Vinterfotbollsplan”/>
    <ServiceUnitTypeInfo id=”ac4854fb-fba3-4d01-83ce-ff7992310846″singularName=”?tervinningscentral”/>
    </ServiceUnitTypeInfos>

    Further information on types of services
    The service type ”Swimming” where the id attribute is used as identifier in the endpoint /Service unit types / ‘.
    http://api.stockholm.se/ServiceGuideService/ServiceUnitTypes/10031f76-001a-4a00-9e2a-3b1a166ebf6f?apikey=yournotsosecretkeyvalue1234

    <ServiceUnitTypesingularName=”Simhall”pluralName=”Simhallar”definitiveName=”Simhallen”timeCreated=”2009-01-07T10:23:38.217″timeUpdated=”2009-01-07T10:23:38.217″>
    <ServiceUnitTypeGroupInfo name=”Idrott/Motion”/>
    <Lists>
    <List uri=”ServiceUnits”/>
    </Lists>
    </ServiceUnitType>

    With the example above you can scroll through the entire database.

  5. Searching
    Method aka ”endpoint” using QueryString ”name” is ”ServiceUnits”
    and can be used to search among services.

    Example:
    http://api.stockholm.se/ServiceGuideService.svc/ServiceUnits?name=akalla&apikey=yournotsosecretkeyvalue1234

  6. Format
    The default format is XML. JSON is supplied by adding the ”json” as a further identifier.

    Example:
    http://api.stockholm.se/ServiceGuideService/ServiceUnitTypes/10031f76-001a-4a00-9e2a-3b1a166ebf6f/json?apikey=yournotsosecretkeyvalue1234

Kategori: eGovernment


1 kommentar

  1. Hi,
    I developed an Android application using the city of Helsinki REST api; today I saw Stockholm offers a similar api, so it could be really simple for me to release a similar application based on the city of Stockholm api (the name will be Go Stockholm).
    Could you please tell me which is the best way to make a general search?
    Due to language difficulties (you seem to provide info only in Swedish), I can’t understand which is the best way to query the database.
    So far I’m able to retrieve ‘museum’ like:

    http://api.stockholm.se/PlaceService/DetailedServiceUnits?ShortDescription=museum&apikey=e5929c796e04403e8f6f3dbbfbe008ef

    but if I want to retrieve ‘sjukhus’ (hospital) in a similar manner:

    http://api.stockholm.se/PlaceService/DetailedServiceUnits?ShortDescription=sjukhus&apikey=e5929c796e04403e8f6f3dbbfbe008ef

    I obtain only 4 items with that word (searching for that word in the page), which is way too few.
    Could you please provide me a general example of a search by word, for instance ‘museum’, ‘metro’ or ‘hospital’?
    I’d be thankful.
    Kind regards,
    Alessio Salvadorini

Lämna ett svar till Alessio Salvadorini Avbryt svar

E-postadressen publiceras inte. Obligatoriska fält är märkta *

Subscribe to comments