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

Help setting up #32

Closed
TheGiolly opened this issue Jan 4, 2022 · 5 comments
Closed

Help setting up #32

TheGiolly opened this issue Jan 4, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@TheGiolly
Copy link

Hi, I'm having some troubles getting ebay_rest to work.

ebay_rest.json (I added the IT header because I'm from Italy)

    "***_instructions_***": {
        "01": "The ebay_rest module needs your eBay credentials.",
        "02": "Copy this file to your working folder and name it ebay_rest.json.",
        "03": "As you create and get, replace the placeholders in the two sections that follow.",
        "04": "Create a developer account - https://developer.ebay.com/api-docs/static/creating-edp-account.html",
        "05": "Get your OAuth credentials - https://developer.ebay.com/api-docs/static/oauth-credentials.html",
        "06": "Get your redirect_uri value - https://developer.ebay.com/api-docs/static/oauth-redirect-uri.html",
        "07": "Create production and sandbox logins at your eBay country-specific marketplace, e.g. https://www.ebay.com & https://sandbox.ebay.com.",
        "08": "Except for production users, scopes will be auto-discovered.",
        "09": "If the token and token_expiry are empty, they will be auto-generated."
    },
    "applications": {
        "production_1": {
            "app_id": "placeholder-placeholder-PRD-placeholder-placeholder",
            "cert_id": "PRD-placeholder-placeholder-placeholder-placeholder-placeholder",
            "dev_id": "placeholder-placeholder-placeholder-placeholder-placeholder",
            "redirect_uri": "placeholder-placeholder-placeholder-placeholder"
        },
        "sandbox_1": {
            "app_id": "my app id",
            "cert_id": "my cert id",
            "dev_id": "my dev id",
            "redirect_uri": "my redirect url"
        }
    },
    "users": {
        "production_1": {
            "email_or_username": "<production-username>",
            "password": "<production-user-password>",
            "scopes": [
                "https://api.ebay.com/oauth/api_scope",
                "https://api.ebay.com/oauth/api_scope/sell.inventory",
                "https://api.ebay.com/oauth/api_scope/sell.marketing",
                "https://api.ebay.com/oauth/api_scope/sell.account",
                "https://api.ebay.com/oauth/api_scope/sell.fulfillment"
            ],
            "refresh_token": "",
            "refresh_token_expiry": ""
        },
        "sandbox_1": {
            "email_or_username": "my email",
            "password": "my password",
            "refresh_token": "",
            "refresh_token_expiry": ""
        }
    },
    "headers": {
        "ENCA": {
            "accept_language": "en-CA",
            "affiliate_campaign_id": "",
            "affiliate_reference_id": "",
            "content_language": "en-CA",
            "country" : "CA",
            "currency": "CAD",
            "device_id": "",
            "marketplace_id": "EBAY_ENCA",
            "zip": "K1M 1M4"
        },
        "GB": {
            "accept_language": "en-GB",
            "affiliate_campaign_id": "",
            "affiliate_reference_id": "",
            "content_language": "en-GB",
            "country" : "GB",
            "currency": "GBP",
            "device_id": "",
            "marketplace_id": "EBAY_GB",
            "zip": "SW1A 1AA"
        },
        "US": {
            "accept_language": "en-US",
            "affiliate_campaign_id": "",
            "affiliate_reference_id": "",
            "content_language": "en-US",
            "country": "US",
            "currency": "USD",
            "device_id": "",
            "marketplace_id": "EBAY_US",
            "zip": "20500"
        },
        "IT": {
            "accept_language": "it-IT",
            "affiliate_campaign_id": "",
            "affiliate_reference_id": "",
            "content_language": "it-IT",
            "country": "IT",
            "currency": "EUR",
            "device_id": "",
            "marketplace_id": "EBAY_IT",
            "zip": "27100"
        }
    }
}

main.py

from ebay_rest import API, DateTime, Error, Reference

print(f"eBay's official date and time is {DateTime.to_string(DateTime.now())}.\n")

print("All valid eBay global id values, also known as site ids.")
print(Reference.get_global_id_values(), '\n')

try:
    api = API(application='sandbox_1', user='sandbox_1', header='IT')
except Error as error:
    print(f'Error {error.number} is {error.reason}  {error.detail}.\n')
else:
    try:
        print("The five least expensive iPhone things now for sale on-eBay:")
        for record in api.buy_browse_search(q='iPhone', sort='price', limit=5):
            if 'record' not in record:
                pass    # TODO Refer to non-records, they contain optimization information.
            else:
                item = record['record']
                print(f"item id: {item['item_id']} {item['item_web_url']}")
    except Error as error:
        print(f'Error {error.number} is {error.reason} {error.detail}.\n')
    else:
        pass

print("\nClass documentation:")
print(help(API))    # Over a hundred methods are available!
print(help(DateTime))
print(help(Error))
print(help(Reference))

Output

eBay's official date and time is 2022-01-04T19:19:15.979Z.

All valid eBay global id values, also known as site ids.
[{'ebay_site_id': '16', 'global_id': 'EBAY-AT', 'language': 'de-AT', 'site_name': 'eBay Austria', 'territory': 'AT'}, {'ebay_site_id': '15', 'global_id': 'EBAY-AU', 'language': 'en-AU', 'site_name': 'eBay Australia', 'territory': 'AU'}, {'ebay_site_id': '193', 'global_id': 'EBAY-CH', 'language': 'de-CH', 'site_name': 'eBay Switzerland', 'territory': 'CH'}, {'ebay_site_id': '77', 'global_id': 'EBAY-DE', 'language': 'en-DE', 'site_name': 'eBay Germany', 'territory': 'DE'}, {'ebay_site_id': '2', 'global_id': 'EBAY-ENCA', 'language': 'en-CA', 'site_name': 'eBay Canada (English)', 'territory': 'CA'}, {'ebay_site_id': '186', 'global_id': 'EBAY-ES', 'language': 'es-ES', 'site_name': 'eBay Spain', 'territory': 'ES'}, {'ebay_site_id': '71', 'global_id': 'EBAY-FR', 'language': 'fr-FR', 'site_name': 'eBay France', 'territory': 'FR'}, {'ebay_site_id': '23', 'global_id': 'EBAY-FRBE', 'language': 'fr-BE', 'site_name': 'eBay Belgium (French)', 'territory': 'BE'}, {'ebay_site_id': '210', 'global_id': 'EBAY-FRCA', 'language': 'fr-CA', 'site_name': 'eBay Canada (French)', 'territory': 'CA'}, {'ebay_site_id': '3', 'global_id': 'EBAY-GB', 'language': 'en-GB', 'site_name': 'eBay UK', 'territory': 'GB'}, {'ebay_site_id': '201', 'global_id': 'EBAY-HK', 'language': 'zh-Hant', 'site_name': 'eBay Hong Kong', 'territory': 'HK'}, {'ebay_site_id': '205', 'global_id': 'EBAY-IE', 'language': 'en-IE', 'site_name': 'eBay Ireland', 'territory': 'IE'}, {'ebay_site_id': '203', 'global_id': 'EBAY-IN', 'language': 'en-IN', 'site_name': 'eBay India', 'territory': 'IN'}, {'ebay_site_id': '101', 'global_id': 'EBAY-IT', 'language': 'it-IT', 'site_name': 'eBay Italy', 'territory': 'IT'}, {'ebay_site_id': '100', 'global_id': 'EBAY-MOTOR', 'language': 'en-US', 'site_name': 'eBay Motors', 'territory': 'US'}, {'ebay_site_id': '207', 'global_id': 'EBAY-MY', 'language': 'en-MY', 'site_name': 'eBay Malaysia', 'territory': 'MY'}, {'ebay_site_id': '146', 'global_id': 'EBAY-NL', 'language': 'nl-NL', 'site_name': 'eBay Netherlands', 'territory': 'NL'}, {'ebay_site_id': '123', 'global_id': 'EBAY-NLBE', 'language': 'nl-BE', 'site_name': 'eBay Belgium (Dutch)', 'territory': 'BE'}, {'ebay_site_id': '211', 'global_id': 'EBAY-PH', 'language': 'en-PH', 'site_name': 'eBay Philippines', 'territory': 'PH'}, {'ebay_site_id': '212', 'global_id': 'EBAY-PL', 'language': 'pl-PL', 'site_name': 'eBay Poland', 'territory': 'PL'}, {'ebay_site_id': '216', 'global_id': 'EBAY-SG', 'language': 'en-SG', 'site_name': 'eBay Singapore', 'territory': 'SG'}, {'ebay_site_id': '0', 'global_id': 'EBAY-US', 'language': 'en-US', 'site_name': 'eBay United States', 'territory': 'US'}] 

The five least expensive iPhone things now for sale on-eBay:

Class documentation:
Help on Multiton in module ebay_rest.multiton object:

API = class Multiton(builtins.object)
 |  API(cls)
 |  
 |  When init parameters match, reuse an old initialized object instead of making a new one.
 |  Objects that have not be been reused for an hour will be dropped from the pool.
 |  
 |  Use this when the cost of object creation is high or there is a big benefit to object sharing.
 |  
 |  Don't use this on data storage classes.
 |  
 |  In ebay_rest, Multiton helps avoid making redundant REST calls to eBay.
 |  Redundant calls waste time, erode daily call limits and can trigger an "Internal Server Error" at eBay.
 |  I suspect the latter is eBay protecting itself from customer code stuck in an endless loop.
 |  
 |  Multiton is a class decorator, and here is an example of how to use it.
 |  
 |  @Multiton
 |  class YourClass:
 |      pass
 |  
 |  Debugging tip, temporarily comment out the decorator is if object reuse is confusing diagnosis.
 |  
 |  To learn about the Multiton Creation (Anti)Pattern, visit https://en.wikipedia.org/wiki/Multiton_pattern.
 |  
 |  Methods defined here:
 |  
 |  __call__(self, *args, **kwargs)
 |      Call self as a function.
 |  
 |  __getattr__(self, attr)
 |  
 |  __init__(self, cls)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |  
 |  __instancecheck__(self, other)
 |      Check if an object is an instance.
 |  
 |  __setattr__(self, attr, value)
 |      Implement setattr(self, name, value).
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)

None
Help on class DateTime in module ebay_rest.date_time:

class DateTime(builtins.object)
 |  Helpers for the specific way that eBay does date-time.
 |  
 |  Static methods defined here:
 |  
 |  from_string(d_t_string: str) -> datetime.datetime
 |      convert an Ebay dateTime string to a python datetime object with eBay's timezone
 |      
 |      string YYYY-MM-DDTHH:MM:SS.SSSZ (e.g., 2004-08-04T19:09:02.768Z)
 |      
 |      :param d_t_string (str, required)
 |      :return: datetime (datetime)
 |  
 |  now() -> datetime.datetime
 |      Get the current time, as a python datetime object with eBay's timezone.
 |      
 |      Date-time values are in the ISO 8601 date and time format.
 |      Hours are in 24-hour format (e.g., 2:00:00pm is 14:00:00).
 |      Universal Coordinated Time (UTC), also known as Greenwich Mean Time (GMT),
 |      also known as Zulu because the time portion of the time stamp ends with a Z.
 |      
 |      :return: datetime (datetime)
 |  
 |  to_string(d_t: datetime.datetime) -> str
 |      convert a python datetime object with eBay's timezone to an Ebay dateTime string
 |      
 |      string YYYY-MM-DDTHH:MM:SS.SSSZ (e.g., 2004-08-04T19:09:02.768Z)
 |      
 |      :param d_t (datetime, required)
 |      :return: datetime (str)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)

None
Help on class Error in module ebay_rest.error:

class Error(builtins.Exception)
 |  Error(number: int, reason: str, detail: str = None) -> None
 |  
 |  Used to return all exceptions from this package.
 |  
 |  End user notes:
 |  When writing exception-handling code, take action based on the error number.
 |  Error numbers are unlikely to change, but the descriptive text will evolve.
 |  
 |  Library maintainer notes.
 |  The error number is composed of a two-digit prefix and a three-digit suffix.
 |  Each new internal module is assigned a unique prefix counting down from 99.
 |  Give new "raises" within a module a unique suffix counting up from 001.
 |  Refrain from repurposing error numbers.
 |  Refrain from altering the error number or text descriptions when re-raising.
 |  
 |  Method resolution order:
 |      Error
 |      builtins.Exception
 |      builtins.BaseException
 |      builtins.object
 |  
 |  Methods defined here:
 |  
 |  __init__(self, number: int, reason: str, detail: str = None) -> None
 |      Instantiate a new Error object.
 |      
 |      :param number (int, required) A unique natural number code.
 |      :param reason (str, required) A short description of the reason.
 |      :param detail (str, optional) The details about the failure, optional.
 |      :return None (None)
 |  
 |  __str__(self) -> str
 |      :return message (str)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  ----------------------------------------------------------------------
 |  Static methods inherited from builtins.Exception:
 |  
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from builtins.BaseException:
 |  
 |  __delattr__(self, name, /)
 |      Implement delattr(self, name).
 |  
 |  __getattribute__(self, name, /)
 |      Return getattr(self, name).
 |  
 |  __reduce__(...)
 |      Helper for pickle.
 |  
 |  __repr__(self, /)
 |      Return repr(self).
 |  
 |  __setattr__(self, name, value, /)
 |      Implement setattr(self, name, value).
 |  
 |  __setstate__(...)
 |  
 |  with_traceback(...)
 |      Exception.with_traceback(tb) --
 |      set self.__traceback__ to tb and return self.
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from builtins.BaseException:
 |  
 |  __cause__
 |      exception cause
 |  
 |  __context__
 |      exception context
 |  
 |  __dict__
 |  
 |  __suppress_context__
 |  
 |  __traceback__
 |  
 |  args

None
Help on class Reference in module ebay_rest.reference:

class Reference(builtins.object)
 |  Caches of reference information sourced from eBay's developer website.
 |  
 |  Static methods defined here:
 |  
 |  get_application_scopes() -> dict
 |      Get eBay **Client Credential/Code** Grant Type Scopes
 |       that might be permitted when minting **Application** tokens.
 |      
 |       Dictionary keys are the scopes, and data are descriptions.
 |      
 |      Source https://developer.ebay.com/my/keys, Sandbox column, click OAuth Scopes, second section
 |      
 |      :return application_scopes (dict)
 |  
 |  get_country_codes() -> dict
 |      Get eBay country code information.
 |      
 |      A partial list of ISO 3166 standard two-letter codes that represent countries around the world.
 |      
 |      Source https://developer.ebay.com/devzone/xml/docs/reference/ebay/types/countrycodetype.html.
 |      
 |      :return country_codes (dict)
 |  
 |  get_currency_codes() -> dict
 |      Get eBay country code information.
 |      
 |      A partial list of standard 3-digit ISO 4217 currency codes for currency used in countries around the world.
 |      
 |      Source https://developer.ebay.com/devzone/xml/docs/Reference/eBay/types/CurrencyCodeType.html.
 |      
 |      :return currency_codes (dict)
 |  
 |  get_global_id_values() -> dict
 |      Get eBay global id information.
 |      
 |      The Global ID is a unique identifier for combinations of site, language, and territory.
 |      Global ID values are returned in globalId and are used as input for the X-EBAY-SOA-GLOBAL-ID header.
 |      The global ID you use must correspond to an eBay site with a valid site ID.
 |      See https://developer.ebay.com/Devzone/merchandising/docs/Concepts/SiteIDToGlobalID.html
 |      eBay Site ID to Global ID Mapping for a list of global IDs you can use with the API calls.
 |      
 |      Source https://developer.ebay.com/Devzone/merchandising/docs/CallRef/Enums/GlobalIdList.html.
 |      
 |      :return global_id_values (dict)
 |  
 |  get_item_enums_modified() -> dict
 |      Get eBay enumeration type definitions and SOME of their values.
 |      
 |      Beware that many values are missing; expect to encounter new ones.
 |      
 |      This has been modified in an opinionated way to aid with SQL database storage.
 |      
 |      Source https://developer.ebay.com/api-docs/buy/browse/enums.
 |      
 |      :return enums_modified (dict)
 |  
 |  get_item_fields_modified() -> dict
 |      Get eBay item "response" field information.
 |      
 |      The root container is ebay_item.
 |      
 |      Details of a specific item can include description, price, category, all item aspects, condition,
 |      return policies, seller feedback and score, shipping options, shipping costs, estimated delivery,
 |      and other information the buyer needs to make a purchasing decision.
 |      
 |      This has been modified in an opinionated way to aid with SQL database storage.
 |      
 |      Source https://developer.ebay.com/api-docs/buy/browse/resources/item/methods/getItem#h2-output.
 |      
 |      :return item_fields_modified (dict)
 |  
 |  get_marketplace_id_values() -> dict
 |      Get eBay marketplace id information.
 |      
 |      The following table lists the set of supported Marketplace IDs, their associated countries,
 |      the URLs to the marketplaces, and the locales supported by each marketplace
 |      
 |      Source https://developer.ebay.com/api-docs/static/rest-request-components.html#marketpl.
 |      
 |      :return marketplace_id_values (dict)
 |  
 |  get_user_scopes() -> dict
 |      Get eBay **Authorization Code** Grant Type Scopes
 |      that might be permitted when minting **User Access** tokens.
 |      
 |      Dictionary keys are the scopes, and data are descriptions.
 |      
 |      Source https://developer.ebay.com/my/keys, Sandbox column, click OAuth Scopes, first section
 |      
 |      :return user_scopes (dict)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)

None

Process finished with exit code 0

What am I doing wrong?
Thanks in advance for any help

@matecsaj
Copy link
Owner

matecsaj commented Jan 4, 2022

You did nothing wrong; eBay's sandbox doesn't appear to currently have any products for the Italian marketplace. When I ran your code with my production account, it found the following items.

item id: v1|402590657482|0 https://www.ebay.it/itm/402590657482?hash=item5dbc45ebca:g:TM4AAOSwmjxf1fOD item id: v1|165109622680|464663407133 https://www.ebay.it/itm/165109622680?hash=item26714ce798:g:EmAAAOSwqTxhXUka item id: v1|165109622679|464663449244 https://www.ebay.it/itm/165109622679?hash=item26714ce797:g:alIAAOSwP-phXUk2 item id: v1|165109622690|464663578370 https://www.ebay.it/itm/165109622690?hash=item26714ce7a2:g:1a0AAOSwFsthXUjj item id: v1|154638932099|454721705352 https://www.ebay.it/itm/154638932099?hash=item240132d883:g:NkMAAOSwD9dhXUia

While considering your issue, I noticed a bug and created a separate issue. #33

Are you satisfied with this response? Can I close your issue?

@matecsaj matecsaj added the bug Something isn't working label Jan 4, 2022
@TheGiolly
Copy link
Author

Oh, I hadn't thought about that!
I'm new to the eBay API world and I just assumed that all the listings present in the production eBay would have also been in the sandbox.
Thanks a lot for your fast response.
I'll close this issue :)

@TheGiolly TheGiolly reopened this Jan 7, 2022
@TheGiolly
Copy link
Author

TheGiolly commented Jan 7, 2022

--IGNORE--

1 similar comment
@TheGiolly
Copy link
Author

TheGiolly commented Jan 7, 2022

--IGNORE--

@matecsaj
Copy link
Owner

One of your remarks was that a timeout was too short. Another user reported the same issue. You may be interested to know that a fix will be in next month's release. #34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants