cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting Access to Browse API

Hi eBay Support,

 

I recently learned eBay is going to discontinue Finding and Shopping API and I see eBay recommends switching to Browse API. Can I ask how to request the access to it? The scopes I need to have access to are below.  Many ebay sellers highly rely on these two APIs and use these for purchasing, sourcing and pricing. Can you please advice?

 

buy.item.summary

buy.guest.checkout

 

Looking forward to hearing from you. 

 

 

 

Message 1 of 4
latest reply
3 REPLIES 3

Getting Access to Browse API

I have the same query (well more specifically about the Buy API), I tried changing the scope as follows:

curl -X POST 'https://api.sandbox.ebay.com/identity/v1/oauth2/token' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Authorization: Basic UkVTVFRlc3...wZi1hOGZhLTI4MmY=' \
  -d 'grant_type=client_credentials&scope=https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope %20https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fbuy.item.bulk'

 

From this page:

https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html

 

However when I try to change the scope I receive the following message:

An error occurred while fetching the token: 400 Client Error: Bad Request for url: https://api.ebay.com/identity/v1/oauth2/token
Response status code: 400
Response content: {"error":"invalid_scope","error_description":"The requested scope is invalid, unknown, malformed, or exceeds the scope granted to the client"}
No

 

One suggestion was to contact eBay support, but there is no option to raise a ticket.

I found this page:

https://developer.ebay.com/api-docs/buy/static/buy-requirements.html#Applying

However it says:

Please note that access to  Order API  |  Offer API  |  Marketplace Insights API  cannot be granted upon request.

So I am still very much in the dark as to how its possible for individuals with small operations to gain access to the buy (including the ability to place orders) api?

Message 2 of 4
latest reply

Getting Access to Browse API

Whilst I still don't have access to the buy API, the browse api seems to work, see if the following works for you:

def get_ebay_token(base_url=BASE_URL, client_id=APP_ID, client_secret=SECRET):
    """
    Generate an eBay application access token using the Client Credentials Grant flow.

    Args:
        base_url (str): Base URL for eBay API (e.g., 'https://api.ebay.com' or 'https://api.sandbox.ebay.com').
        client_id (str): Your eBay application's Client ID.
        client_secret (str): Your eBay application's Client Secret.

    Returns:
        str: The access token if successful, None otherwise.
    """
    token_url = f"{base_url}/identity/v1/oauth2/token"
    credentials = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()
    headers = {'Authorization': f'Basic {credentials}', 'Content-Type': 'application/x-www-form-urlencoded'}
    data = {'grant_type': 'client_credentials', 'scope': f'{base_url}/oauth/api_scope'}

    try:
        response = requests.post(token_url, headers=headers, data=data)
        response.raise_for_status()
        token_data = response.json()
        access_token = token_data.get('access_token')
        if access_token:
            print(f"Successfully obtained access token. Expires in {token_data.get('expires_in', 'unknown')} seconds.")
            return access_token
        else:
            print("Token not found in response:", token_data)
            return None
    except requests.RequestException as e:
        print(f"An error occurred while fetching the token: {e}")
        print(f"Response status code: {response.status_code if 'response' in locals() else 'N/A'}")
        print(f"Response content: {response.text if 'response' in locals() else 'N/A'}")
        return None

 

def get_ebay_listings(input_csv, base_url=BASE_URL, site_id='EBAY_GB'):
    # Read the input CSV to get item titles
    df = pd.read_csv(input_csv)
    item_titles = df['Title'].tolist()

    # Headers for the request
    headers = {
        "Authorization": f"Bearer {get_ebay_token()}",
    }

    headers["X-EBAY-C-MARKETPLACE-ID"] = site_id

    # Initialize an empty list to store item data
    items = []

    # Iterate over each item title
    for title in item_titles:
        logging.info(f"Fetching price history for: {title}")

        # Construct the search URL
        search_url = f'{base_url}/buy/browse/v1/item_summary/search?q={title}&limit=200'

        # Make the request
        response = requests.get(search_url, headers=headers)

        # Check if the request was successful
        if response.status_code == 200:
            data = response.json()
            for item in data.get('itemSummaries', []):
                item_data = {
                    'Title': item.get('title'),
                    'Price': item.get('price', {}).get('value'),
                    'Currency': item.get('price', {}).get('currency'),
                    'Condition': item.get('condition'),
                    'Seller': item.get('seller', {}).get('username'),
                    'ItemID': item.get('itemId'),
                    'URL': item.get('url')
                }
                items.append(item_data)
        else:
            logging.info(f"Request failed for title '{title}' with status code: {response.status_code}")
            logging.info(f"Response Content: {response.content}")

    # Convert the list of items to a DataFrame
    df = pd.DataFrame(items)

    return df

 

That works for me (although it does seem a bit inconsistent in the explorer, haven't used this script enough to comment on whether this always works or is intermittent, but currently it is working for me).

Message 3 of 4
latest reply

Getting Access to Browse API

thanks for sharing! will give this a try! I was getting error message saying I don't have the access. That's why I thought I might need to have more scopes. 

Message 4 of 4
latest reply