As national protests over the death of unarmed black men by white police officers pushed race relations to the top of the headlines, President Barack Obama revealed his own experiences of racism, including being mistaken for a waiter and a parking valet.

In an interview with People magazine published on Wednesday, Obama and his wife, Michelle Obama, said that before moving into the White House nearly six years ago, they faced prejudice, stereotyping and had trouble catching taxis.

"There is no black male my age, who's a professional, who hasn't come out of a restaurant and is waiting for their car and somebody didn't hand them their car keys," President Obama told the magazine, adding that this had happened to him.