I am interested in getting constituents of an index along with individual stock returns on a 1m,1y, 5y basis through bloomberg terminal as well as through api. Do we have a single command which can serve this purpose ?
There's no single field to return constituents AND data on those constituents. So yes, you need first to query the index constituents and then do queries for the data you want on those securities.
Once you've got the list of constituents, for the returns you can use a number of different fields.
Assuming you're looking at equities and want the total return (including dividends etc...) two particularly useful ones are:
The first one will give you a single number for the net return between two dates (use the CUST_TRR_START_DT and CUST_TRR_END_DT overrides to define them) while the second one will give you a series of periodic net returns between two dates.
in excel you'd do something like:
=bdp("AAPL US Equity",
<insert a function or pointer to the start date in YYYYMMDD format>,
to get the single 1m, 1y, 5y etc... returns you want to see.
That's a flexible solution, alternatively you'll see that securities often have a number of fixed fields for particularly popular holding periods. e.g:
In general in Bloomberg, if you have access to a terminal, go to a security's page and type
FLDS <search term> <GO> to find field codes to use for the API/Excel add-in. That and the helpdesk tends to be where I start.