Ability obtain id to next max id instead of full link.

I want to implement infinity scroll of user's photos on my page.
I don't want to send to user link to next page and don't want to store this link in session.
I don't want to cut next id from the link (it is not durable).