top of page

Categories

Archive

Hong Kong Government Data API

  • Kenneth Li
  • Feb 26, 2017
  • 2 min read

O, our government finally built up the API for data provided in data.gov.hk. Let's see how we can make use of it.

However, the documentation is not really helpful because there is no sample url call but a small piece of code for "real" developers. So I look into the "Build a Query". Great! I can get the result. The url does not look good though.

After several minutes test and research, I converted the url into something readable. Therefore, I can see the query structure and it would be easier to perform future tasks.

Before:

https://api.data.gov.hk/v1/filter?q=%7B%22resource%22%3A%22http%3A%2F%2Fidds.census2011.gov.hk%2FMain_tables%2FBatch_04%2FD302.XLSX%22%2C%22section%22%3A2%2C%22format%22%3A%22json%22%7D

After:

https://api.data.gov.hk/v1/filter?q={"resource":"http://idds.census2011.gov.hk/Main_tables/Batch_04/D302.XLSX","section":2,"format":"json"}

Oops, if I put the converted url to a browser, I got a bad request. Probably there is decoding issues. I also put the original url, it directed me to download an unknown file which can be opened with notepad and containing the json format data. Anyway, I would rather say the API is not sophisticated enough since user cannot even query with a browser.

When it goes to Alteryx, things become simpler. Just put the url as an input for download tool (remember to check to box "Encode URL text"), then you will get the result from the server.

Afterwards, it's only some tricks to transform the data into rows and columns.

Overall, I found three points interesting:

1. The API is not typical. I have built several workflows to access the data through API with Alteryx, usually I will test the query with browser before moving on so I have an idea on what would I get. In this case, seems the query with browser is not available and even took time to do investigation. Apparently the API is not user-friendly.

2. The data available are not useful, diverse, not to mention "real time". If you check carefully the data available in different categories, first of all, most of them are not up-to-date and the update frequency is very low; second of all, the API basically allow the access to the ready-made excel but not a database server...why would I need to do extra thing to access an excel while I can download it directly.

3. One good thing is that the API does not apply authentication and query limitation so far (probably they do not think many access will appear!) which makes the whole process simpler. This policy should maintain until more useful and exciting improvement has been done and the server is almost overwhelmed.

Happy Alteryx!


Recent Posts

See All
How to pass PMP at first attempt

I passed the PMP on 7 Mar 2018, which is my first attempt. I read quite a lot of comments online saying that the exam is quite tricky and...

 
 
 
諮詢類工作配對的三大條件以及海投的十分之一

自一月底通知「被離職」後,花了很大力氣去找新的機會。對於本來打算於這小公司打拼一段三至五年時間的我,一下子打亂了計劃,但日子總要過,總不能每天沉醉在思考事件為何發生。反省固然有必要,只是積極面對來得更迫切。 終於在差不多三個月後陸績收到幾份聘書,其中有些是心儀的,也有些是轉...

 
 
 

© 2017 by Kenneth Li

Li's Analytics

bottom of page