Skip to main content

ebay_rest

A Python 3 pip package that wraps eBay’s REST APIs.

Table of Contents


Installation

Basic Installation

The basic installation provides core functionality without browser automation. It is lighter, easier to install, and sufficient for most use cases.

pip install ebay_rest

Complete Installation

The complete installation includes browser automation for getting eBay user tokens.

pip install ebay_rest[complete]

After installing the package, install Playwright and Chromium:

playwright install chromium

Note: Playwright may require additional system dependencies. See Playwright installation guide for details.


Setup

Follow the setup instructions in the example configuration file.


Usage

Here is a basic example of using ebay_rest to retrieve eBay's global site IDs and search for iPhones:

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='production_1', user='production_1', header='US')
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(error)    # Another way to print an error.
    else:
        pass

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

Look to the unit tests for more example code.


FAQ

How are API results structured?
  • Basic types: strings, integers, dates.
  • dict (objects): Groups related elements.
  • list (arrays): Repetitive structures with one or more elements.
  • Optional elements may be omitted, mandatory elements are set to None if empty.
How are paged API results handled?
  • A Python generator is used instead of a list.
  • Do not supply an "offset" parameter.
  • "limit" controls how many records to retrieve.
  • To retrieve all records, omit "limit." Be aware of eBay's 10,000 record count limit.
Can the browser automation be avoided?

Yes, reuse the refresh token after the first retrieval. Modify your ebay_rest.json file:

"refresh_token": "your_refresh_token",
"refresh_token_expiry": "your_token_expiry"
  
Does this library support threading/multiprocessing?

Threading is safe. Multiprocessing is untested (help wanted).

Why does eBay return "Internal Error"?

Making repeated calls with the same parameters in a short time can trigger this error.

How can I upload a file?

See the sample code in the unit tests. Search for usages of get_upload_sample_path_file to find working examples.

How can I get data from a response header?

See the sample code in the unit tests. Search for test_commerce_media_upload_video to find a working example.

How can I implement eBay’s publish/subscribe workflow?

Push delivery is not possible with this library; a workaround is to use the Client Alerts (poll) option seen on a screenshot on this page.


Optimization & Performance

To optimize API calls:

  1. Cache responses to avoid redundant API calls.
  2. Use filters to limit response data.
  3. Use generators instead of lists for paged results.
  4. Utilize threading (but be mindful of rate limits).
  5. Reuse the API instance to avoid unnecessary authentication overhead.
  6. Optimize your network (faster internet connection, lower latency).

Contributing

Contributions are welcome! Please fork this repository and submit a pull request. Follow the coding standards outlined in CONTRIBUTING.md.


Legal

Release files for ebay-rest 1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ebay-rest 1.1.4
File Size Uploaded
ebay_rest-1.1.4.tar.gz 1.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for ebay-rest 1.1.4
File Interpreter ABI Platform
ebay_rest-1.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 4.6 MB

Release files / ebay_rest-1.1.4.tar.gz

Download URL ebay_rest-1.1.4.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
79c3a1713e0605c42513b796beb7d73325c76ced300437c5deee6c756ab63f86
BLAKE2b-256 checksum
How to use checksums
44c5c4bd613e0d0e63611696b1dee76d6920f994eae87174397698a428a92c65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / ebay_rest-1.1.4-py3-none-any.whl

Download URL ebay_rest-1.1.4-py3-none-any.whl
Size 3.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
93758824fecfec61dd2244a39efe69877d051e3fba361f8795de7fac13f399fe
BLAKE2b-256 checksum
How to use checksums
1cdce591cec7147db893523fb56ed84381a661c5a80e715c8f3f91db3a48caaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

1.1.4 This release

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.13

2 release files

1.0.9

2 release files

1.0.8

1 release file

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

0.0.36

2 release files

0.0.35

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.30

2 release files

0.0.29

2 release files

0.0.28

2 release files

0.0.19

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page