In the first exchange, Luke Chadwick fired just over with his left foot, but Cardiff were able to take an early lead when Alan Lee smashed the ball home after a low cross from their left by Paul Parry.
Chadwick was then set up by a Bobby Zamora back heel but Tony Warner dived at his feet to deny him.
At the other end, Darren Williams tried his luck but Steve Bywater was equal to it - but he could do nothing about Joe Ledley's strike after he cleverly controlled a Jobi McAnuff cross, cut inside Hayden Mullins, and fired home his first goal for the club.
Finding themselves two down after barely a quarter of an hour, West Ham tried to respond, but Cardiff were making the running, and Steve Bywater just kept out a third goal when he tipped a Gary O'Neil free kick onto the bar after Carl Fletcher had fouled McAnuff.
Marlon Harewood struck a free kick wide before hitting two speculative efforts that Warner was equal to.
He then had to thank his defenders for a double clearance off the line; Fletcher's corner was met with a Davenport header that was scrambled away by O'Neil, and, while he was appealing that it had crossed the line, Harewood's follow-up was also hooked away by Graham Kavanagh.
Fletcher was then unlucky with a half volley that flashed wide as the Hammers ended the half desperately looking to claw a goal back.
After the break, Chris Barker had a header saved from a McAnuff cross before Don Hutchison replaced Luke Chadwick; he went up front and Harewood switched to the right.
Moments later, after West Ham were unable to clear, Alan Lee played a deft ball inside the West Ham defence and Paul Parry pushed the ball beyond the despairing dive of Steve Bywater.
Jobi McAnuff tried to make it four against his old club after cutting inside Rufus Brevett, but his left foot shot flashed just wide of the far post.
Harewood and Zamora saw efforts go wide and over respectively, before the Hammers got a glimmer of hope; after a run from just inside his own half past several Cardiff players, Kavanagh was adjudged to have fouled him.
Harewood himself coolly slotted home the spot kick to reduce the deficit to 3-1.
Sergei Rebrov replaced Hayden Mullins at the same time as Chris Powell came on for Rufus Brevett; West Ham switched to a three man-defence with Rebrov looking to add creativity up front.
Shortly afterwards, though, any hopes of a fight back were knocked back when, almost inevitably, McAnuff scored his first goal for Cardiff since his move from Upton Park earlier in the season.
He slipped home a pass from Ledley, but, to his credit, his celebration was modest.
Luke Chadwick returned to the starting line-up, in place of Nigel Reo-Coker, who had a knee problem.
Sergei Rebrov, who missed the trip to Plymouth through injury, was added to the bench.