Earlier in the pandemic, e-commerce stocks won as people opted to stay home and shop rather than go to stores -- and in many cases the stores weren't even open. But as routines returned and stores opened their doors, e-commerce companies no longer were the only game in town. That and rising inflation weighed on the sector last year. And as a result, earnings of some of the biggest players suffered.

The good news, though, is the general economic environment is improving, and top e-commerce companies are recovering. Two to watch are Amazon (AMZN 2.29%), a seller of essentials and general merchandise, and Etsy (ETSY 1.56%), a platform for the selling and buying of handmade items. Both of these stocks are promising -- but which makes the better buy right now? Let's find out.

The case for Amazon

Amazon last year reported its first annual loss in almost 10 years. Higher inflation weighed on its costs and on consumers' ability to spend. At the same time, Amazon struggled with excess fulfillment capacity. The company had doubled its network in a short period of time as the pandemic fueled demand. As a result, Amazon's shares also suffered, falling almost 50%.

But Amazon took action early on, with efforts to improve its cost structure. The company cut tens of thousands of jobs, shifted investments into its highest-growth areas, kept cloud computing customers loyal by offering them lower-priced solutions, and even made changes to make deliveries more efficient. These moves are bearing fruit, and investors have taken notice.

In the most recent quarter, sales and operating income increased -- and the company shifted to net income from a loss in the year-earlier period. Amazon shares are winning too, with an increase of 57% so far this year.

All of this shows Amazon made it through the difficult times and now is on track for a new phase of growth. The company should benefit over time from its leadership in the high-growth businesses of e-commerce and cloud computing. Developments in the hot area of artificial intelligence (AI) also should help Amazon as the company already uses the technology across its businesses.

The case for Etsy

Etsy has been spared some of the impact of rising inflation thanks to its business model. The company offers a platform for artisans to sell their goods online -- but Etsy doesn't handle the storage or transport of these products.

In fact, Etsy doesn't have to make huge capital investments to spur growth, and that's great news for the business in any economic environment. This capital light structure allows the company to transform most of its adjusted EBITDA into free cash flow.

ETSY Free Cash Flow Chart

ETSY Free Cash Flow data by YCharts

Of course, the difficult economic context has weighed on Etsy to a certain degree. Higher inflation still makes it more costly for any type of business to operate. Unfavorable currency exchanges also have been a headwind. Finally, in times of uncertainty, people often hesitate to buy non-essential items -- like the sorts of items found on Etsy.

So, Etsy's gross merchandise sales (GMS) and profit have been on the decline. But it's important to look beyond just a quarter or two. Here, we can see that Etsy actually has increased quite a bit since the early pandemic surge in business -- and it's kept most of the gains. For example, Etsy Marketplace GMS have soared 164% from the first quarter four years ago to the first quarter of this year. And in the same time period, active buyers have climbed 119%.

All of this means there's reason to be optimistic about Etsy's growth once the economic environment improves.

Amazon or Etsy?

Both of these e-commerce companies make great long-term investments today. But if I had to buy just one with the idea of benefiting from recovery, I would go with Etsy. Amazon has increased a lot this year, and at a certain point, the pace of gains may slow.

Etsy hasn't yet taken off, and the stock remains dirt cheap, trading at 23 times forward earnings estimates. At the same time, Etsy's capital light business model supports free cash flow growth and makes it less vulnerable during tough economic times. I also like the fact that Etsy has kept so much of its early pandemic growth. So, right now is the perfect time to scoop up shares of this promising player and possibly benefit as the company recovers and grows.