Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The endpoint should be /stores/{brandEntityId}/asinMetrics #192

Closed
denisneuf opened this issue Feb 8, 2024 · 4 comments
Closed

The endpoint should be /stores/{brandEntityId}/asinMetrics #192

denisneuf opened this issue Feb 8, 2024 · 4 comments

Comments

@denisneuf
Copy link
Owner

The endpoint should be /stores/{brandEntityId}/asinMetrics per docs.

Originally posted by @tilschuenemann in #190 (reply in thread)

@denisneuf denisneuf changed the title The endpoint should be /stores/{brandEntityId}/asinMetrics per [docs](https://advertising.amazon.com/API/docs/en-us/stores/open-api#tag/Stores-Analytics/operation/getAsinEngagementForStore). The endpoint should be /stores/{brandEntityId}/asinMetrics Feb 8, 2024
@denisneuf
Copy link
Owner Author

Please I added in last commit that endpoint, could you please check @tilschuenemann

from ad_api.api import Stores
from ad_api.base import Marketplaces, AdvertisingApiException

def get_asin_engagement_for_store(brand_entity_id: str = None, data: dict = None):
    logging.info("---------------------------------")
    logging.info("getAsinEngagementForStore")
    logging.info("---------------------------------")

    try:

        result = Stores(account=store, marketplace=marketplace, debug=True).get_asin_engagement_for_store(
            brandEntityId=brand_entity_id,
            body=data
        )

        '''
        logging.info(result)
        payload = result.payload
        logging.info(payload)
        '''

        # location = payload.get("location")


    except AdvertisingApiException as error:

        logging.info(error)

if __name__ == '__main__':

    dictionary = \
        {
            "endDate": "2024-01-02",
            "orderBy": "ASC",
            "sortBy": "UNITS",
            "metrics": [
            "RENDERS",
            "VIEWS",
            "IN_STOCK_VIEWS",
            "AVERAGE_IN_STOCK_PRICE",
            "IN_STOCK_RATE",
            "CLICKS",
            "CLICK_RATE",
            "ADD_TO_CARTS",
            "ORDERS",
            "UNITS",
            "AVERAGE_SALE_PRICE",
            "CONVERSION_RATE"
            ],
            "dimension": "ASIN",
            "startDate": "2024-01-01"
        }

    get_asin_engagement_for_store('ENTITY11234567890', dictionary)

Hi @drewxa please have a look if you have time and confirm if I upload a new version

@tilschuenemann
Copy link

@denisneuf
Thank you for the implementation! Sadly, we can't test getAsinEngagementForStore as engagement metrics aren't enabled for our store.

When trying the other endpoint, an exception occurs:

from ad_api.api import Stores
from ad_api.base import Marketplaces, AdvertisingApiException
import logging

credentials = {
    "refresh_token": "Atzr|IwEB......",
    "client_id": "amzn1.....",
    "client_secret": ".....",
    "profile_id": ".....",
}


def get_asin_engagement_for_store(brand_entity_id: str = None, data: dict = None):
    logging.info("---------------------------------")
    logging.info("getAsinEngagementForStore")
    logging.info("---------------------------------")

    try:
        result = Stores(
            credentials=credentials, marketplace=Marketplaces.IT, debug=True
        ).get_insights_for_store_api(brandEntityId=brand_entity_id, body=data)
        logging.info(result)
        payload = result.payload
        logging.info(payload)

        # location = payload.get("location")

    except AdvertisingApiException as error:

        logging.info(error)


if __name__ == "__main__":

    dictionary = {
        "startDate": "2024-01-01",
        "endDate": "2024-02-29",
        "dimension": "PAGE",
        "maxResult": 1500,
        "metrics": ["VIEWS"],
    }

    get_asin_engagement_for_store("MYENTITY", dictionary)
2024-03-04 14:24:40,147:INFO:{"startDate": "2024-01-01", "endDate": "2024-02-29", "dimension": "PAGE", "maxResult": 1500, "metrics": ["VIEWS"]}
2024-03-04 14:24:40,147:INFO:{'_content': b'{"message":"\'Atza|IwE.....\' not a valid key=value pair (missing equal-sign) in Authorization header: .......

I'll look into this some more when I get the time.

@denisneuf
Copy link
Owner Author

Yes I had the same result with the other endpoint but according the Amazon should be ok, I will release it when I got time and if some other could test or find problems we could fix later

@denisneuf
Copy link
Owner Author

v0.5.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants