Every level (including the boss levels) of Story Mode has 5 badges that are earned by:
Completing the level
Collecting 1/3 of the total coins in the level
Shooting all of the chests in the level
Shooting all of the targets in the level (pop-up cut-outs of enemies)
Collecting all the power-ups in the level
The exact amount of coins, chests, targets, and power-ups will vary for each level depending on what paths you choose (there are many forks in the road of each level). There is generally several hundred coins, 2 to 4 chests, 3 to 9 targets, and 2 to 6 power-ups.
All of the badges do NOT need to be earned on the same playthrough of the level. So for example, you could get badges 1,2, and 3 on the first playthrough, and badges 4 and 5 on another playthrough and you are good to go. You can check what badges you still need in the level selection screen. You need to click on the boss levels to see those particular badges you are missing.
NOTE: Power-up badges can not be earned until you spend the coins to unlock all of them from the store (it will say 0 out of 0 in the end screen after completing a run for the power-up badge).