The game was heading for a stalemate until the two teenagers struck late on.
It ensured Pools first win of 2014 and inflicted a first loss of the new year on the Minstermen.
James, after 82 minutes, took a knock down from Jack Baldwin and powered home a confident shot into the bottom corner of the net from the edge of the area.
But Barmby stole his thunder seven minutes later.
Signed on Thursday on loan from Manchester United, the attacker had only been on the pitch for 10 minutes when he scored.
The son of former England international Nicky curled a fine shot into the top corner of the net from 20 yards out.
"We scored two good goals. A lot of credit goes around because York have been strong of late on a good run, not giving much away to teams,'' said Cooper.
"It was a lovely bit of quality for our first goal, a lovely cushioned header from Jack Baldwin for him.
"It was a nice finish. Good technique into the bottom corner. It was lovely.
"We knew York would come at us straight away and it allowed us to pick them off. If we get in front, we can get two, three and four.''
Of Barmby, Cooper added: "Jack, from when we spoke to him, wants to come and impress people and show why he is at Manchester United. He wants to play football.
``We spoke on Friday after training and I said he may have to be a bit patient with me, but I said he would get on and I said I would love to give him a game when he can express himself and enjoy himself.
"Considering it's his first taste of football he wanted the ball, was productive and put defenders on the back foot. We are very lucky to have him.''
York manager Nigel Worthington was left to rue a defensive error which brought Pools' opener.
Josh Carson gifted them the chance to put the ball into the area and Worthington moaned: "It's hard to take. The performance for 80 minutes was very good, very strong and resilient and we competed - it was a good game overall.
"The situation of how the first goal comes about is disappointing because it's down to indiscipline.
"Josh Carson gives away a stupid free-kick 20 yards from goal when he had the opportunity to clear the ball up the line.
"It's silly. The ball comes into the box and finished up in the back of the net. It knocks the stuffing out of you.
"Then they get a second because their tails are up. So it's how you deal with it.''
- Sports & Recreation
- Manchester United
- Jack Baldwin