Registry / http-networking / ebay-api

ebay-api

JSON →
library9.5.1jsnpmunverified

The `ebay-api` package provides a comprehensive client library for interacting with both the Traditional (XML) and modern RESTful eBay APIs, supporting Node.js and browser environments. Currently at version 9.5.1, it offers robust functionality for accessing various eBay services, including Buy, Commerce, and others, with an active release cadence reflecting ongoing development and API updates. Key differentiators include built-in support for multiple authentication flows like client credentials grant, authorization code grant (OAuth2, Auth'N'Auth), and Digital Signatures, simplifying complex eBay authentication processes. It also ships with TypeScript types, enhancing developer experience and type safety for large-scale applications.

npm install ebay-api
INSTALL
IMPORT
SIG · EBAY-API
E
ebay-api
http-networkingjavascriptv9.5.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

eBayApi
✓ import eBayApi from 'ebay-api';
✗ import { eBayApi } from 'ebay-api';
`eBayApi` is the default export of the module. Attempting to import it as a named export will result in an undefined value or a runtime error.
Config
✓ import type { Config } from 'ebay-api';
✗ import { Config } from 'ebay-api';
When importing only types in TypeScript, always use `import type` to ensure no runtime code is generated, preventing potential import errors or unnecessary bundle sizes.
eBayApi.fromEnv
✓ import eBayApi from 'ebay-api'; const eBay = eBayApi.fromEnv();
✗ import { fromEnv } from 'ebay-api';
`fromEnv` is a static method of the `eBayApi` class, designed to load configuration from environment variables. It should be called directly on the imported default `eBayApi` class, not imported as a standalone named export.

This quickstart demonstrates how to initialize the eBay API client using environment variables for credentials and fetch details for a specific item using the Buy Browse API, including error handling.

import eBayApi from 'ebay-api'; import 'dotenv/config'; // Optional: for loading .env variables // Ensure your eBay Developer credentials are set as environment variables (e.g., EBAY_APP_ID, EBAY_CERT_ID) // You can obtain these from your eBay Developer Program account: https://developer.ebay.com/signin?tab=register const EBAY_APP_ID = process.env.EBAY_APP_ID ?? '-- also called Client ID --'; const EBAY_CERT_ID = process.env.EBAY_CERT_ID ?? '-- also called Client Secret --'; const EBAY_RUN_IN_SANDBOX = process.env.EBAY_RUN_IN_SANDBOX === 'true'; // Set to 'true' in .env for sandbox if (EBAY_APP_ID === '-- also called Client ID --' || EBAY_CERT_ID === '-- also called Client Secret --') { console.error('Error: Please configure your eBay API credentials. Check your .env file or direct configuration.'); process.exit(1); } const eBay = new eBayApi({ appId: EBAY_APP_ID, certId: EBAY_CERT_ID, sandbox: EBAY_RUN_IN_SANDBOX, // Set to true for sandbox environment; false for production // siteId: 0 // Example: Specify site ID for certain traditional APIs (e.g., 0 for US) }); async function getExampleItem() { try { // Example: Fetch details for a specific item using the Buy Browse API const itemId = 'v1|254188828753|0'; // A publicly accessible sample item ID console.log(`Fetching item details for ID: ${itemId}...`); const item = await eBay.buy.browse.getItem(itemId); console.log('Successfully fetched item details:'); console.log(JSON.stringify(item, null, 2)); // Uncomment for a search example: // console.log('\nPerforming a search for "laptop"...'); // const searchResults = await eBay.buy.browse.search({ q: 'laptop', limit: 3 }); // console.log('Search Results:'); // console.log(JSON.stringify(searchResults.itemSummaries, null, 2)); } catch (error: any) { console.error('An error occurred during the API call:', error.message || error); if (error.response) { console.error('Detailed API Error Response:', error.response.data); } } } getExampleItem();
Debug
Known issues
breakingIn `v7.0.0`, the API configuration introduced `returnResponse`. If set to `true`, API calls will return the full HTTP response object instead of directly returning the data payload.
fix
If your application relied on API calls directly returning the data, ensure `returnResponse` is either `false` in your configuration or adjust your code to access `response.data`.
affects: >=7.0.0
gotchaIncorrect configuration of `appId` (Client ID), `certId` (Client Secret), or `sandbox` mode is a common source of authentication and authorization errors. Using production keys in the sandbox environment or vice-versa will lead to unexpected behavior or failures.
fix
Always verify that your `appId`, `certId`, and `sandbox` setting correctly match the environment (production or sandbox) and credentials you obtained from the eBay Developer Program.
affects: >=1.0.0
gotchaeBay's API ecosystem utilizes several distinct authentication flows (Client Credentials, Authorization Code Grant/OAuth2, Auth'N'Auth, Digital Signature). Choosing the wrong flow for a specific API operation or incorrectly implementing the chosen flow can lead to persistent authorization errors.
fix
Refer to the official eBay API documentation and the `ebay-api` library's guides for the correct authentication method required for the specific API endpoint you are targeting. Ensure refresh tokens are managed properly for long-lived access.
affects: >=1.0.0
Errors
Common errors & fixes
"Unauthorized" or "Authentication required"
Missing or invalid API credentials (`appId`, `certId`) or an expired/incorrect access token.
fix
Ensure `appId` and `certId` are correctly configured in `eBayApi` constructor or environment variables. Verify your access token is valid and refreshed if using OAuth2/Auth'N'Auth.
"Invalid API call, API error, or missing required parameter"
An incorrect endpoint, missing required parameters for an API call, or a malformed request body.
fix
Consult the eBay API documentation and the `ebay-api` library examples for the specific API call. Double-check required parameters and their format.
"This API is not supported in the sandbox environment" or "The resource you requested cannot be found."
Attempting to call an eBay API that is only available in the production environment while `sandbox` is set to `true`, or the API version is not supported in the current environment.
fix
Change `sandbox: false` in your `eBayApi` configuration and use production credentials if the API is production-only. Alternatively, check if a sandbox equivalent exists for your desired API or if you are using an outdated API version.
Upgrade
Version history
9.5.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
34 hits · last 30 days
node
28
OpenAI (training)
1
Resources
ebay-api — npm install ebay-api · libregistry