sapientpro/ebay-browse-sdk-php

PHP SDK for Ebay Browse API

v1.0.0 2023-06-27 14:49 UTC

This package is not auto-updated.

Last update: 2024-04-22 14:43:29 UTC


README

Using the Browse API, you can create a rich selection of items for your buyers to browse with keyword and category searches.

  • API version: v1.18.4

Requirements

  • PHP 8.1 and later
  • ext-json and ext-curl extensions enabled

Installation & Usage

Install the package using composer:

composer require sapientpro/ebay-browse-sdk-php

Getting Started

Please follow the installation procedure and then run the following:

<?php
use SapientPro\EbayBrowseSDK\Configuration;
use SapientPro\EbayBrowseSDK\Api\ItemApi;
use SapientPro\EbayBrowseSDK\Models\CompatibilityPayload;

// Configure OAuth2 access token for authorization: api_auth
$config = Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');

$apiInstance = new ItemApi(
config: $config
);
// you can create and fill a Model class that implements EbayModelInterface using fromArray() method
// exception will be thrown if a property does not exist in the model class
$body = CompatibilityPayload::fromArray([]);

try {
$result = $apiInstance->checkCompatibility($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling InventoryItemApi->bulkCreateOrReplaceInventoryItem: ', $e->getMessage(), PHP_EOL;
}

Creating Models

Some SDK methods require $body variable as a parameter. It refers to a Model class that implements EbayModelInterface. There are several ways to create a Model class:

fromArray()

You can create a Model class using fromArray() method. It will throw an exception if a property does not exist in the model class.

If the model has a property of type that implements EbayModelInterface, you must create an instance of that class using fromArray() method. In this example, the property price is of type ConvertedAmount that also implements EbayModelInterface.

Item::fromArray([
    'price' => ConvertedAmount::fromArray([
        'value' => '6.90',
        'currency' => CurrencyCodeEnum::USD
    )]
])

fromPlainArray()

It is also possible to create a Model from plain associative array. The previous example can be rewritten as follows:

Item::fromPlainArray([
    'price' => [
        'value' => '6.90',
        'currency' => CurrencyCodeEnum::USD
    ]
])

fromJson()

It is also possible to create a Model from JSON string.

Item::fromJson('{"price": {"value": "6.90", "currency": "USD"}}')

Documentation for API Endpoints

All URIs are relative to https://api.ebay.com/buy/browse/v1

Class Method HTTP Method Path
ItemSummaryApi search GET /item_summary/search
ItemSummaryApi searchByImage POST /item_summary/search_by_image
ItemApi getItem GET /item/{item_id}
ItemApi getItemByLegacyId GET /item/get_item_by_legacy_id
ItemApi getItems GET /item/
ItemApi getItemsByItemGroup GET /item/get_items_by_item_group
ItemApi checkCompatibility POST /item/{item_id}/check_compatibility

Documentation for Models

Class Description
AdditionalProductIdentity The type that defines the array of product identifiers associated with the item. This container is returned if the seller has associated the eBay Product Identifier (ePID) with the item and in the request <b> fieldgroups</b> is set to <code>PRODUCT</code>.
AddonService This container describes an add-on service that may be selected for an item or that may apply automatically. A charge may be associated with the add-on service.
Address The type that defines the fields for an address.
Amount
Aspect The type that defines the fields for the name/value pairs for the aspects of the product. For example: BRAND/Apple
AspectDistribution The type that define the fields for the aspect information. Aspects are the variations of an item, such as color, size, etc.
AspectGroup
AspectValueDistribution The container that defines the fields for the conditions refinements. This container is returned when <b> fieldgroups</b> is set to <code>ASPECT_REFINEMENTS</code> or <code>FULL</code> in the request.
AttributeNameValue The type the defines attribute name/value pair fields that specify a product. The type of data depends on the context. For example, if you were using this to specify a specific vehicle, the attribute names would be Make, Model, Year, etc.
AuthenticityGuaranteeProgram A type that identifies whether the item is qualified for the Authenticity Guarantee program.
AuthenticityVerificationProgram A type that identifies whether the item is from a verified seller.
AutoCorrections
AvailableCoupon
BuyingOptionDistribution The container that defines the fields for the buying options refinements. This container is returned when <b> fieldgroups</b> is set to <code>BUYING_OPTION_REFINEMENTS</code> or <code>FULL</code> in the request.
Category This type is used by the <b>categories</b> container in the response of the <b>search</b> method, and contains the name and ID of the item category.
CategoryDistribution The container that defines the fields for the category refinements. This container is returned when <b> fieldgroups</b> is set to <code>CATEGORY_REFINEMENTS</code> or <code>FULL</code> in the request.
CommonDescriptions The type that defines the fields for the item ids that all use a common description. Often the item variations within an item group all have the same description. Instead of repeating this description in the item details of each item, a description that is shared by at least one other item is returned in this container. If the description is unique, it is returned in the <b> items.description</b> field.
CompatibilityPayload An array of attribute name/value pairs used to define a specific product. For example: If you wanted to specify a specific car, one of the name/value pairs would be <br><code>"name" : "Year", <br>"value" : "2019"</code> <p> For a list of the attributes required for cars and trucks and motorcycles see <a href="/api-docs/buy/static/api-browse.html#Check">Check compatibility</a> in the Buy Integration Guide.</p>
CompatibilityProperty This container returns the product attribute name/value pairs that are compatible with the keyword. These attributes are submitted in the <b>compatibility_filter</b> request field.
CompatibilityResponse The type that defines the response fields for <b> checkCompatibility</b>.
ConditionDistribution The container that defines the fields for the conditions refinements. This container is returned when <b> fieldgroups</b> is set to <code>CONDITION_REFINEMENTS</code> or <code>FULL</code> in the request.
ConvertedAmount This type defines the monetary value of an amount. It can provide the amount in both the currency used on the eBay site where an item is being offered and the conversion of that value into another currency, if applicable.
CoreItem An array of containers with the details for all of the items returned.
CouponConstraint This type is used to provide the expiration date of a coded coupon.
Error The type that defines the fields that can be returned in an error.
ErrorParameter An array of name/value pairs that provide details regarding the error.
EstimatedAvailability The type that defines the fields for the estimated item availability information.
HazardPictogram A type that defines the pictogram for the type of hazard that a hazardous material represents.
HazardStatement A type that defines the hazard statement for a hazardous material.
HazardousMaterialsLabels A type that defines the hazardous materials labels for an item.
Image Type the defines the details of an image, such as size and image URL. Currently, only <b> imageUrl</b> is populated. The <b> height</b> and <b> width</b> were added for future use.
Item The details of an item that can be purchased.
ItemGroup The type that defines the fields for the item details.
ItemGroupSummary The type that defines the fields for the details of each item in an item group. An item group is an item that has various aspect differences, such as color, size, storage capacity, etc. When an item group is created, one of the item variations, such as the red shirt size L, is chosen as the "parent". All the other items in the group are the children, such as the blue shirt size L, red shirt size M, etc. <br><br><span class="tablenote"><b> Note: </b> This container is returned only if the <b> item_id</b> in the request is an item group (parent ID of an item with variations).</span>
ItemLocationImpl The type that defines the fields for the location of an item, such as information typically used for an address, including postal code, county, state/province, street address, city, and country (2-digit ISO code).
ItemReturnTerms The type that defines the fields for the seller's return policy.
ItemSummary The type that defines the fields for the details of a specific item.
Items Container for a list of items.
LegalAddress Type that defines the fields for the seller's address.
MarketingPrice The type that defines the fields that describe a seller discount.
PaymentMethod
PaymentMethodBrand
PickupOptionSummary The type that defines the fields for the local pickup options that are available for the item. It is used by the <b> pickupOptions</b> container.
Product The type that defines the fields for the product information of the item.
ProductIdentity The type that defines the fields for the product identifier type/value pairs of product associated with an item.
RatingHistogram The type that defines the fields for product ratings. Only products that are in the eBay product catalog can be reviewed and rated.
Refinement This type defines the fields for the various refinements of an item. You can use the information in this container to create histograms, which help shoppers choose exactly what they want.
Region This type is used to provide region details for a tax jurisdiction.
ReviewRating The type that defines the fields for the rating of a product review.
SearchByImageRequest The type that defines the fields for the image information.
SearchPagedCollection The type that defines the fields for a paginated result set. The response consists of 0 or more sequenced <em> pages</em> where each page has 0 or more items.
Seller The type that defines the fields for basic information about the seller of the item returned by the <b> item_summary</b> resource.
SellerCustomPolicy The container for custom policies that apply to a listed item.
SellerDetail The type that defines the fields for basic and detailed information about the seller of the item returned by the <b> item</b> resource.
SellerLegalInfo The type that defines the fields for the contact information for a seller.
ShipToLocation The type that defines the fields for the country and postal code of where an item is to be shipped.
ShipToLocations The type that defines the fields that include and exclude geographic regions affecting where the item can be shipped. The seller defines these regions when listing the item.
ShipToRegion This type is used provide details about included and excluded shipping regions.
ShippingOption The type that defines the fields for the details of a shipping provider.
ShippingOptionSummary The type that defines the fields for the shipping information.
TargetLocation The type that defines the fields for the distance between the item location and the buyer's location.
TaxJurisdiction The type that defines the fields for the tax jurisdiction details.
Taxes The type that defines the tax fields.
TimeDuration The type that defines the fields for a period of time in the time-measurement units supplied.
TypedNameValue The type that defines the fields for the name/value pairs for item aspects.
VatDetail The type the defines the fields for the VAT (value add tax) information.

Authorization

api_auth