Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Andersen1
Frequent Visitor

How to consume Stats Canada API

Hi Friends,

 

Im trying to consume data from Stats Canada API and I have read through their WDS documentation but everything I try I run into errors. Im just wondering if anyone in the community has successfully leveraged their API?

 

Thanks 

2 REPLIES 2
Bizzie
Frequent Visitor

Hi, I am wondering if it is possible to use the "Get" functions to only retrieve specific time series (vectors).  I have been able to pull full tables in, as you mention above, and I have been able to get "Json.Document(Web.Contents("https://www150.statcan.gc.ca/t1/wds/rest/getAllCubesList"))" to pull in cube information, but I cannot get queries for specific vectors or productIDs to work.  Is it possible to do using Power Query?

 

Thanks for any help!!

 

Update:

My apologies, I did get this to work:

Source =
Json.Document(
Web.Contents("https://www150.statcan.gc.ca/t1/wds/rest/getDataFromVectorByReferencePeriodRange?vectorIds=""""1"""",""""2""""&startRefPeriod=2016-01-01&endReferencePeriod=2017-01-01")
)

as an example.  Thanks all!

mahoneypat
Microsoft Employee
Microsoft Employee

It looks like a standard API.  Which method/query are your requesting?  If you are trying the get the one to get the CSV download, but it is zipped and unzipping files is tricky (unless it is gzip or one of the compression types Power BI handles easily).  This post has a method to do it, if you are comfortable with M queries.

http://sql10.blogspot.com/2016/06/reading-zip-files-in-powerquery-m.html

 

If not, you should be able to download the zip file, decompress it, and then use Power BI to load the csv file data.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.