Biking through Boston's downtown or around Harvard Square might seem treacherous, but cycling specialists rank both urban areas among the top 50 bike-friendly cities in the nation. 

Every two years, Bicycling, which proclaims itself as "the world's leading cycling magazine," crunches the numbers to find the best bicycling cities in the country.

This year's ranking saw Cambridge moving up the list by two spots, from number 10 in 2014 to eighth place. Boston fell slightly from spot 16 in 2014 to 17. 

Bicycling's rankings are based on data from the U.S. census and the department of transportation, expert input from organizations like the Alliance for Biking & Walking and the League of American Bicyclists.

RELATED: Bicycling advocates push for safer streets

List-makers look at everything from how many miles of bike lanes a city has to what percentage of the cycling commuters are female—an indictor, Bicycling writes, "of safe bike infrastructure."

Cambridge earned honors for its recent cycling infrastructure improvements like the protected bike lane on Western Avenue, which national cycling advocacy group People for Bikes named as the best new bike lane in the country of 2015. 

Cambridge also touted the highest percentage of female bike commuters in Bicycling's top ten cities at 44 percent, which the magazine says shows how safe it is to cycle around the city.

"And, though crashes do occur, fatalities are rare, thanks to narrow streets, traffic-calming measures, and the resulting low vehicle speeds," Bicycling wrote. "In 2014, after a cyclist was sideswiped by a garbage truck, the city installed sideguards on all of its large vehicles."

RELATED: Boston paving way for protected bike lane installations

Boston has seen little progress over the years in terms of its bicycling infrastructure, the magazine notes, though it once had a strong streak of progress under Mayor Thomas Menino. The mayor once exclaimed "The car is no longer king," and his efforts helped bring Boston up from Bicycling's "worst city for cycling" designation.

Though riders may not have seen many changes recently, they're in the works: In 2017, the city will reveal the beginnings of a $23 million network of protected bike lanes encircling Boston's central business district and North End, according to Bicycling. 

The city also committed to redesigning Commonwealth Avenue last year to include more protected lanes—that street has had the highest number of accidents involving cyclists slamming into open car doors.

The city that's best for biking, according to Bicycling? Chicago, thanks in part to Mayor Rahm Emanuel's plan to build 50 miles of bikeways after he added 100 miles of protected lanes during his first term.

See the full list here