2

I am testing an idea before turning it into code, and I want to retrieve Twitter DMs for a user. I am using the Twitter Console to test everything out.

According to the docs for both direct_messages and direct_messages/sent (emphasis mine);

Returns the 20 most recent direct messages sent by the authenticating user. Includes detailed information about the sender and recipient user. You can request up to 200 direct messages per call, up to a maximum of 800 outgoing DMs.

I want to grab that maximum 800, I have tried two types of call for this — What am I doing wrong or is there a mistake in the API docs?;

Using Pages

Using count and pages I figured I would be able to page through to page 4 with a count of 200 (making the 800).

https://api.twitter.com/1.1/direct_messages.json?count=200&page=1 works and returns 200 results https://api.twitter.com/1.1/direct_messages.json?count=200&page=2 works but returns 0 results

The same happens when using direct_messages/sent.json

Using max_id

When calling https://api.twitter.com/1.1/direct_messages.json?count=200 I noted that the returned DMs are ordered by the newest first. So I grabbed the ID of the earliest DM of the 200 and fed that into max_id, assuming then this would give me the next 200 that were earlier than this.

https://api.twitter.com/1.1/direct_messages.json?count=200&max_id=482007447041609700 works but returns 0 results

Notes

  • I have more than 200 DMs in my account.
  • You have to authenticate with oAuth in the Twitter console to test out these URLs
  • I found a thread on the Twitter Dev forums of others experiencing this

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.