Foreman API get all hosts

hi all,

when I call https://myserver/api/v2/hosts/ I get only 24 hosts, how can I get all hosts back?
its there a way like hosts parameter : https:///myserver/api/v2/hosts/270/parameters?per_page=1000

thank you all

?per_page=all
is the answer thank you all

2 Likes
?thin=1

If you just need the list of names and ids. It’s much faster.

1 Like

Thank you @angry_yak_shaver ?thin=1 return only id and hostname and it’s really fast!

But if you want more than ID and Hostname, it’s not possible to do that with ?thin=1, if you have any idea or know how can we combine ?thin=1 with other parameters it would be really helpful.

Thanks again

Happy to be proved wrong but IMHO there is no free lunch - either you get the list quickly without the DB joins or you wait for the backend to do the work and get the full results.

you are right @angry_yak_shaver , but the full results take tooooo much time! so Im looking for other one… its possible to change the DB joins ? so I dont want select ALL( * ) columns…

Hello again months after. I do script around the api a bit and I ended up catching some of the long calls locally in a SQLite db. I used a modified version of this:

https://atmb4u.github.io/cashier/

Very handy.

1 Like

I meant to say caching instead of catching :slight_smile:

yes I get you :slight_smile: ill check it out :slight_smile: thanks @angry_yak_shaver