The Bluebirds made four changes as they looked to end their run of three defeats while the Hammers were unchanged after beating Newcastle 2-0 last weekend.
On a blustery day in the Welsh capital, the hosts made the perfect start when Junior Hoilett opened the scoring after four minutes. The Bluebirds forged an overlap down the right and after Josh Murphy fired in a ball towards the near post, Hoilett was on hand to convert.
The Hammers looked shell shocked and struggled to settle into the game, with their only attacking moment of note in the first half coming when Javier Hernandez received a yellow card for a dive in the area.
Manuel Pellegrini raised eyebrows by withdrawing Felipe Anderson at the break, although things did not get any better for the Chilean's side as they fell 2-0 behind on 52 minutes.
This time it was a ball from the left and it was Murphy with his second assist as his nod down found Camarasa, who got in ahead of Lukasz Fabianski and bundled home.
Cardiff could have been even further ahead had Oumar Niasse taken his chances but, to their credit, they were much sharper nearer their own goal, with Sean Morrison and Bruno Ecuele-Manga frustrating West Ham at every turn.
The Hammers' best chance came through a Declan Rice effort which cannoned off the post, but the visitors were just not up to scratch on the day.