OpenBazaar / openbazaar-go

OpenBazaar 2.0 Server Daemon in Go
MIT License
991 stars 284 forks source link

OpenBazaar API return empty price #2071

Closed ghost closed 4 years ago

ghost commented 4 years ago

After openbazaar-go upgrade, API returns empty price. How to properly upgrade old-version database? Should I remove some data from the .openbazaar folder?

server 0.14.1

hoffmabc commented 4 years ago

What API call are you making?

ghost commented 4 years ago

https://api.docs.openbazaar.org

I use openbazaar-go v0.14.1 to collect search index. For example, some listings without price presented in this search result also have empty price value through direct API call, but Client v2.4.3 works fine, how is it possible.

hoffmabc commented 4 years ago

From 0.14.0 and up the pricing values have changed a bit to support ETH style currencies and different divisibilities of currencies. We need to update the API docs.

When scraping listings indexes you will now see this for price:

"price": {
            "amount": "20",
            "currency": {
                "code": "USD",
                "currencyType": "fiat",
                "divisibility": 2,
                "name": "United States Dollar"
            }
        },

When scraping an individual listing you will see this:

"item": {
            "title": "Casio F91W-1 Classic Resin Strap Digital Sport Watch",
            "description": "<p>A tried and true style great for casual wear. With its daily alarm, hourly time signal and auto calendar, you&#39;ll never need to worry about missing an appointment again. Black Casual Classic watch with a Resin Band. Accuracy: ± 30 Seconds a month                </p>",
            "processingTime": "",
            "price": 0,
            "nsfw": false,
            "tags": [
                "Clothing, Shoes &amp; Jewelry",
                "Men",
                "Watches",
                "Wrist Watches"
            ],
            "images": [
                {
                    "filename": "1588451376538",
                    "original": "QmNr9QHTK5A39V3xjnKAsK8MwwMSwW8FMCRSu65sJVbPFY",
                    "large": "QmZWppsF2ez7FuHmqJJmtqWvt7CLmDeNYF2M4AMhujNeya",
                    "medium": "QmXRYJpQBcV5iwpvuw5WfALr3YcruKRjGFudqAXT8AE7gT",
                    "small": "QmdsT79FYUZV2L7hYHajHETPPzwG3wmE6Dv3GVUyM4rSG1",
                    "tiny": "QmfPmEEMH4EDakV8m1tuLdzUr3SQfp9xxppxW34fsFrR9h"
                }
            ],
            "categories": [
                "Clothing, Shoes &amp; Jewelry"
            ],
            "grams": 0,
            "condition": "",
            "options": [
            ],
            "skus": [
                {
                    "productID": "",
                    "surcharge": 0,
                    "quantity": 0,
                    "bigSurcharge": "0",
                    "bigQuantity": "-1"
                }
            ],
            "priceModifier": 0,
            "bigPrice": "1069",
            "priceCurrency": {
                "code": "USD",
                "divisibility": 2
            }
        },

Notice how the legacy price attribute is 0 now and that bigPrice is now the value with priceCurrency describing the currency that was used to price it in.

ghost commented 4 years ago

Thank you, it works!

hoffmabc commented 4 years ago

Great