A toddler was sleeping in a house when at least two gunshots were fired through the front windows, police said.
The incident occurred at about 11.30pm on Saturday night in the Rossdowney Drive area of the Waterside in Londonderry.
The Police Service of Northern Ireland (PSNI) said a number of people were in the house at the time of the gun attack, including the child who was asleep upstairs.
Detective Constable Donnell said someone could have been killed.
"It is very fortunate that we are not dealing with a death," the officer said.
"The house where this incident occurred was occupied at the time and a toddler was sleeping in a room upstairs.
"This was an extremely reckless act in which we believe at least two shots were fired through the front windows of the property."
Detectives at Strand Road appealed for anyone who was in the area at the time and may have witnessed the incident or anyone who heard shots being fired or saw anyone fleeing the scene to contact police.
Sinn Féin councillor Christopher Jackson claimed the shooting was sectarian.
"Thankfully no one was injured in this incident but it must have been a frightening experience for those in the area at the time," he said.
"There is no place for guns on the streets of our city and those behind these attacks need to end their war with the community."
Gary Middleton, DUP MLA for Foyle, described the shooting as disturbing and worrying.
"This would have been a terrifying experience for the inhabitants. The reality is today we could have been mourning the loss of life," he said.
"These actions are serious and criminal. I will continue to liaise with the police on this incident."
SDLP councillor Martin Reilly added his condemnation of the attack.
"This was a reckless and sinister attack on a home in our city that could have so easily become a tragedy," he said.
"There's no place for gunmen on the streets of this city or anywhere else. Those responsible for this attack need to face justice."