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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
efilipe
Helper IV
Helper IV

Date limitation on the API

Hi guys,

 

Socialbakers has a limitation for date_start and date_end that cannot be over 3 months.

 

I want to setup the API for the whole next year, to be up and running. Do I have to use "get data" 3 times?

 

This is the code

 

let
data = [ date_start = "2019-10-01",
date_end = "2019-12-31",
profiles= {"8282828282"},
fields= {"attachments", "author_id", "comments","created_time","id","interactions","likes","message","type","url","insights_engagement","insights_impressions","insights_reach","insights_saved","insights_video_views"}
],
header = [ #"Authorization"="Basic TWpBek9UiMDExYTcxOWRkOWMwZGIwYzAxYWI2NGViMDUz",
#"Content-Type"= "application/json; charset=utf-8"],
response = Web.Contents("https://api.socialbakers.com/1/instagram/profile/posts",[Content=Json.FromValue(data),Headers=header]),
out = Json.Document(response,1252),
data1 = out[data],
posts = data1[posts],
#"Converted to Table" = Table.FromList(posts, Splitter.SplitByNothing(), null, null, ExtraValues.Ignore),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"attachments", "author_id", "comments", "created_time", "id", "interactions", "likes", "message", "type", "url", "profile_id", "insights_engagement", "insights_impressions", "insights_reach", "insights_saved", "insights_video_views"}, {"Column1.attachments", "Column1.author_id", "Column1.comments", "Column1.created_time", "Column1.id", "Column1.interactions", "Column1.likes", "Column1.message", "Column1.type", "Column1.url", "Column1.profile_id", "Column1.insights_engagement", "Column1.insights_impressions", "Column1.insights_reach", "Column1.insights_saved", "Column1.insights_video_views"}),
#"Expanded Column1.attachments" = Table.ExpandListColumn(#"Expanded Column1", "Column1.attachments"),
#"Expanded Column1.attachments1" = Table.ExpandRecordColumn(#"Expanded Column1.attachments", "Column1.attachments", {"images", "videos"}, {"Column1.attachments.images", "Column1.attachments.videos"}),
#"Expanded Column1.attachments.videos" = Table.ExpandListColumn(#"Expanded Column1.attachments1", "Column1.attachments.videos"),
#"Expanded Column1.attachments.videos1" = Table.ExpandRecordColumn(#"Expanded Column1.attachments.videos", "Column1.attachments.videos", {"url"}, {"Column1.attachments.videos.url"}),
#"Expanded Column1.attachments.images" = Table.ExpandListColumn(#"Expanded Column1.attachments.videos1", "Column1.attachments.images"),
#"Expanded Column1.attachments.images1" = Table.ExpandRecordColumn(#"Expanded Column1.attachments.images", "Column1.attachments.images", {"url"}, {"Column1.attachments.images.url"})
in
#"Expanded Column1.attachments.images1"

 

Thanks!

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @efilipe ,

You can try to create a table to manually pagination your API to invoke this API multiple times with different parameters and merge them to one to get full records.

Below is a custom function to use start, end date to generate a splittable:

let
    fxGeTable=(start as date,end as date) =>
    let
        range=Duration.Days(end-start),
        ConvertToTable=Table.FromList(List.Numbers(1,range/90),Splitter.SplitByNothing(), {"Index"}, null, ExtraValues.Error),
        addStart=Table.AddColumn(ConvertToTable,"Start",each Date.AddDays(start,([Index]-1)*90)),
        addEnd=Table.AddColumn(addStart,"End",each if end>= Date.AddDays([Start],89) then Date.AddDays([Start],89) else end ),
        result=Table.TransformColumnTypes(addEnd,{{"Index",type number},{"Start",type date},{"End",type date}})
    in
        result
in
    fxGeTable

7.png

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

HI @efilipe ,

You can try to create a table to manually pagination your API to invoke this API multiple times with different parameters and merge them to one to get full records.

Below is a custom function to use start, end date to generate a splittable:

let
    fxGeTable=(start as date,end as date) =>
    let
        range=Duration.Days(end-start),
        ConvertToTable=Table.FromList(List.Numbers(1,range/90),Splitter.SplitByNothing(), {"Index"}, null, ExtraValues.Error),
        addStart=Table.AddColumn(ConvertToTable,"Start",each Date.AddDays(start,([Index]-1)*90)),
        addEnd=Table.AddColumn(addStart,"End",each if end>= Date.AddDays([Start],89) then Date.AddDays([Start],89) else end ),
        result=Table.TransformColumnTypes(addEnd,{{"Index",type number},{"Start",type date},{"End",type date}})
    in
        result
in
    fxGeTable

7.png

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.