# Shouldn't I use \`since\` parameter for recursive fetch?

**URL:** <https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150>\
**Category:** Troubleshooting\
**Created:** [November 13, 2018, 11:14am UTC](https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150 "2018-11-13T11:14:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoh1496](https://avatars.discourse-cdn.com/v4/letter/y/839c29/32.png) [@yoh1496](https://forum.mattermost.com/u/yoh1496)\
**Post date:** [November 13, 2018, 11:14am UTC](https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150/1 "2018-11-13T11:14:39Z")

</div>

Hi,

I’m making a script to fetch all of posts which posted on specified day.

So, I tried to use `page` and `per_page` queries to fetch recursively. But I cannot specify the date when the they were created with `since` query.

Detail are below.

1. Trying with only ‘per\_page’ query

```auto
$ curl -X GET -H 'Authorization: Bearer XXXXXXXXX' -i 'http://localhost/api/v4/channels/channelId/posts?per_page=1'

```

then, I obtained only 1 post.

1. Trying with `since` query

```auto
$ curl -X GET -H 'Authorization: Bearer XXXXXXXXX' -i 'http://localhost/api/v4/channels/channelId/posts?per_page=1&since=1'

```

then, I obtained 113 posts ( all of posted were fetched ).

If you have any suggestion to make my script work, please let me know how to use.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [November 13, 2018, 6:11pm UTC](https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150/2 "2018-11-13T18:11:59Z")

</div>

Hi @yoh1496,

This thread might help: [Getting posts for a channel on a specific date](https://forum.mattermost.com/t/getting-posts-for-a-channel-on-a-specific-date/3560).

Let me know if it doesn’t help and I can ask our developers for more information.

---

<div class="post-metadata">

**Author:** ![yoh1496](https://avatars.discourse-cdn.com/v4/letter/y/839c29/32.png) [@yoh1496](https://forum.mattermost.com/u/yoh1496)\
**Post date:** [November 14, 2018, 12:23am UTC](https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150/3 "2018-11-14T00:23:37Z")

</div>

Hi amy.blais,

Thanks for your reply. I read the thread before, and I didn’t understand how to fetch all of posts ( perhaps, there is need to use `page` parameter iteratively ).

If there are 600 posts in channel, I think you need to request with parameters below.

- { `per_page` : 200, `page`: 0 }
- { `per_page` : 200, `page`: 1 }
- { `per_page` : 200, `page`: 2 }

And I want to specify the `since` parameter.

- { `since`: xxxxxxxxxxxx, `per_page`: 200, `page`: 0 }
- { `since`: xxxxxxxxxxxx, `per_page`: 200, `page`: 1 }
- …

But there is no difference in the results obtained with above 2 parameters.

So, I thought there is no way to use both `since` and `page` (or `per_page` ) parameters and post this thread.

I apologize my explanation is not clear enough. Thanks.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [November 14, 2018, 12:42am UTC](https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150/4 "2018-11-14T00:42:51Z")

</div>

Hi @yoh1496,

Would you like to ask about this in our [community server’s Developer channel](https://community.mattermost.com/core/channels/developers). That way you’ll get a quicker response from one of our developers (and possibly also from one of our community members who might know the answer). If you need any help, just let me know and I can also post the question there.

---

<div class="post-metadata">

**Author:** ![yoh1496](https://avatars.discourse-cdn.com/v4/letter/y/839c29/32.png) [@yoh1496](https://forum.mattermost.com/u/yoh1496)\
**Post date:** [November 14, 2018, 1:16am UTC](https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150/5 "2018-11-14T01:16:42Z")

</div>

Hi amy.blais,

I posted in developer channel.  
Thank you for suggestion.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [November 14, 2018, 7:48pm UTC](https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150/6 "2018-11-14T19:48:24Z")

</div>

Hi @yoh1496,

Seems like your post didn’t get replies so just letting you know that I also posted your question to “API v4” channel, and I’ll ping a developer if I don’t get responses either.

---

<div class="post-metadata">

**Author:** ![yoh1496](https://avatars.discourse-cdn.com/v4/letter/y/839c29/32.png) [@yoh1496](https://forum.mattermost.com/u/yoh1496)\
**Post date:** [November 15, 2018, 2:29am UTC](https://forum.mattermost.com/t/shouldnt-i-use-since-parameter-for-recursive-fetch/6150/7 "2018-11-15T02:29:50Z")

</div>

Hi, @amy.blais,

Thank you for your kindness.

I found workaround for this problem ( `per_page` query does not work with `since` parameter ).  
So, I don’t care they wouldn’t reply me.

The workaround is to use `before` query to iterative fetching as below.

Firstly, get initial result with `since` query.  
Secondly, look the newest post in initial result and if it is not newer than specified date, use the `ID` as `before` query and request again.

Perhaps It may work.  
If it does not work, I’ll post here again.
