You would need a filter on the API side (e.g. 'https://rickandmortyapi.com/api/character?page_size=2'. Unfortunately I don't see one implemented for the rickandmortyapi.
https://rickandmortyapi.com/documentation/
Instead, it uses pagination through the page parameter, which allows you to fetch results in chunks of 20 by default.