In 5e, magic items aren't as common or as varied like in older editions, but that also means it is hard to place prices on them. As DM, NPC's can't really sell a magic item because we don't know the prices for these items. While it is stated they are rare an usually unpurchasable and unsellable, but I still have to have some basis on what to price them. So is there a way to find buying and selling prices for magic items in 5e?
On page 133 of the Dungeon Master's Guide, there is a table labelled Magic Item Rarity which gives a rough guidelines on the value of magical items, from Common rarity (for 50gp upwards) through to Legendary rarity (for 50,000gp or more).
Canon RAW answer is that the DMG gives some orientative guidelines, as @Tashio mentioned.
Some players think that the rarity classification leaves much to be desired, however; Giant in the Playground user Saidoro wrote the article Sane Magic Item Prices to address the problem, you might want to check it out and adapt it to your own needs.
I don't know if the problem you are trying to solve is one of supplying prices for players trying to sell or buy magic items, or just finding a way to facilitate general magic item commerce. In the former case, the DMG has a very rough guide for prices based on rarity on page 133. If you are just looking for a way to allow players to buy and sell items, I would suggest using a modified barter system.
In my game, I decided that a believable (not realistic, that's another matter entirely) economy probably couldn't handle the huge sums that players want to transact on the spot. How much do 10,000 gold pieces weigh? How does Joe Shopkeeper store or transport that much gold without every thief in the city after him?
So I have instituted what I would call a magic broker, or agent. This is a person who can connect you with someone who might have the thing you are looking for, or at least something similar. He doesn't have an inventory of vorpal swords, but he knows a guy who has a dagger of poison he'd like to unload, and another guy with a +1 ax... He also knows an adventurer who really needs a potion of giant strength, and another looking for a ring of protection. In short, tell him what "magic surplus" you have, and he keeps a record. When someone comes along who needs it, he will contact you. For a small brokerage fee, of course.
He does have a small inventory of items that he knows will traffic easily (potions of healing, scrolls), but for the most part, he networks adventurers. It's a system that allows you to control the items available (no one can buy the arrow of dragon slaying that would derail your campaign, no matter how much gold they have), while allowing for interesting role play and barter encounters, back alley deals with dubious trading partners, and tough choices for players. All without creating Ye Olde Magic Shoppe.
Obviously, this choice works best in a large campaign city, with a high concentration of adventurers, but if your campaign has one nearby, it's a perfect spot.
Wizards have released an Unearthed Arcana article called Downtime that gives the players tasks they can pursue between adventures. These include buying, selling, and crafting magic items, along with prices based on rarity.
I have a really simple solution that is book legal, follows all the rules, gives the players something to do with that Giganotosaurus-sized pile of gold, and doesn’t completely break the game.
You simply use the hoard table and selling magic items rules…in reverse. The player decides he wants to trade in/sell his wind-fan and look for a +1 ANYTHING ELSE.
You simple ask the player how long he intends to be in town and ask for the list of items he is looking for..Important note, players don’t know squat, therefore they don’t know what’s in the book!!!!! Without a super awesome and targeted divination or massive arcana and gather information check or a quest tip they will not know what they seek.
They will say something like “I want an awesome weapon… so I can kill that quest thing that doesn’t die, unless I have an awesome weapon…”. Then you being the lazy DM that you are don’t want to send them on another side quest to get the +1 sword of “goes through DR because that iron golem wrecks my world”. So your list will end up looking like:
Thing that makes my spells work better,
A way to come back from squishing.
You take that list and you set up a table based on the party’s CR hoard table. for example say this is a 5-10 CR party and you are on the 5 to 10 CR table. You make a table with 5 columns.
Common >29, Uncommon>64, Rare>81, Very Rare>94, Legendary>98.
Your player’s list is the rows. To fill this table you I.D the percentages where each type of item becomes available based on the Hoard table as shown above. Finally, you roll d100 on each item. If you roll above the rarity type needed they can get the item or even one that does the job better.
Then you go through and come up with the items of the rolled rarity that can get the job done and randomly roll which one they find. So d12 determines which of the 12 possible uncommon items they could get to help spells hit harder etc. If the rarity they roll is too low, they can’t find it.
Next you roll on the selling items table how long it takes to connect with a seller same as connecting with a buyer so 1d6 days for uncommon. If the PC doesn’t wait around that long they can’t get an in with the local lord who is strapped for cash, cause women + booze = poor, and has the item.
Then the seller (NPC aka you the dm) rolls to see what kind of offer he thinks he can get. Your PC is effectively the buyer on the selling a magic item table. You apply mods as normal and roll to give them a price adjusted from the base price listed in salable magic items. Important note: 5e keeps things rather obvious, pattern-wise, so 500 gp uncommon, 5000gp rare, 50000 gp very rare… which means…. you guessed it 500000, for legendary, and should you be so inclined 5000000gp for an artifact.
Then DM up a reason why the offered price tag is so wonky. “Why is this +1 blowgun is obviously worth 750gp? Because that’s how much my bar tab is.” Suddenly all that coin is actually useful. At the same time items are still rare, expensive and difficult to find. I also like to ensure there is some kind of framing event and opposing villain trying to scheme that item away from you but that is just me.