FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-amazon-mws/examples/get_fees.py at examples/xml · python-amazon-mws/python-amazon-mws · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Jan 4, 2025. It is now read-only.
python-amazon-mws
/
python-amazon-mws
Public archive
Notifications
You must be signed in to change notification settings
Fork
204
Star
380
Code
Issues
2
Pull requests
1
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-amazon-mws
/
examples
/
get_fees.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (45 loc) · 2.11 KB
Breadcrumbs
python-amazon-mws
/
examples
/
get_fees.py
Copy path
File metadata and controls
52 lines (45 loc) · 2.11 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import
os
from
uuid
import
uuid4
from
mws
import
Products
from
mws
.
models
.
products
import
FeesEstimateRequest
,
MoneyType
,
PriceToEstimateFees
from
mws
.
mws
import
Marketplaces
# You can add your credentials here if you don't want to use environment variables
ACCESS_KEY
=
None
SECRET_KEY
=
None
ACCOUNT_ID
=
None
def
get_fees
():
"""
Get amazon fees estimate for a single product
"""
# Refer to the amazon documentation for this call as it links you through to the models used for
# these calls for more information on what they expect.
# Lets use the models already made in PythonAM
# Refering to the signature for the .get_my_fees_estimate we need the following
# price_to_estimate_fees requires a MoneyType for our price
my_price
=
MoneyType
(
amount
=
123.45
,
currency_code
=
"GBP"
)
# This is a MoneyType for shipping which is passed into the price_to_estimate_fees for shipping
my_shipping
=
MoneyType
(
amount
=
0.00
,
currency_code
=
"GBP"
)
# Combine the my_price and my_shipping into one PriceToEstimateFees object to send into the API call
my_product_price
=
PriceToEstimateFees
(
listing_price
=
my_price
,
shipping
=
my_shipping
)
# Create a unique Id for this call (the uuid module is great for this)
my_unique_identifier
=
str
(
uuid4
())
# Put it all together and send it off to amazon for their response.
my_product
=
FeesEstimateRequest
(
Marketplaces
.
UK
.
marketplace_id
,
id_type
=
"ASIN"
,
id_value
=
"B07QR73T66"
,
price_to_estimate_fees
=
my_product_price
,
is_amazon_fulfilled
=
False
,
identifier
=
my_unique_identifier
,
)
result
=
products_api
.
get_my_fees_estimate
(
my_product
)
print
(
result
)
if
__name__
==
"__main__"
:
ACCESS_KEY
=
os
.
environ
[
"MWS_ACCESS_KEY"
]
if
ACCESS_KEY
is
None
else
ACCESS_KEY
SECRET_KEY
=
os
.
environ
[
"MWS_SECRET_KEY"
]
if
SECRET_KEY
is
None
else
SECRET_KEY
ACCOUNT_ID
=
os
.
environ
[
"MWS_ACCOUNT_ID"
]
if
ACCOUNT_ID
is
None
else
ACCOUNT_ID
products_api
=
Products
(
access_key
=
ACCESS_KEY
,
secret_key
=
SECRET_KEY
,
account_id
=
ACCOUNT_ID
,
region
=
"UK"
)
# get fees for a single product
get_fees
()
Back
|
FazBrowse Home
|
New Git URL