To get the basic info of the storage of the pool
const bondedPools = await api.query.nominationPools.bondedPools(pool_id);
console.log(`----- Storage for bonded pools: ${bondedPools} -----`);
And to get the rewards accumulated for the pool (When a members payout is claimed, the balance comes out for here):
const rewardPools = await api.query.nominationPools.rewardPools(pool_id);
console.log(`----- Reward pools: ${rewardPools} -----`);
To get the information for a certain pool member (With their Account ID):
const poolMemberInfo = await api.query.nominationPools.poolMembers("13KTxXt8FnzoraYSkQNddrmb6sTvEY2VKyg8J9c1jRGPzF5D");
console.log(`----- Member Info: ${poolMemberInfo} -----`);
Then if you want to automate the process to join a pool, nominate, bond tokens.... check the docs about how to call a Extrinsic with PolkadotJS: https://polkadot.js.org/docs/substrate/extrinsics/#nominationpools