Clients
pypricecharting.pricecharting.PriceCharting
Synchronous PriceCharting API client.
Reuse one client for all requests and close it when done (with or close()).
TOKEN_KEY = 'PRICECHARTING_TOKEN'
class-attribute
instance-attribute
Environment variable the token is read from when none is passed.
__init__(token=None, base_url=BASE_URL, transport=None)
Create a client authenticated with a PriceCharting API token.
The token is redacted from httpx2 request logs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
The 40-character PriceCharting API token. If omitted, it is read from the
|
None
|
base_url
|
str
|
API base URL. Override it to use a mock server. |
BASE_URL
|
transport
|
BaseTransport | None
|
Custom |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the token is missing or not 40 characters. |
close()
Close the underlying HTTP client.
__enter__()
Enter the context and return the client.
__exit__(exc_type, exc_value, traceback)
Close the underlying HTTP client on exit.
product(id=None, upc=None, q=None)
Get a single product by exactly one of id, upc, or q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str | None
|
PriceCharting product ID. |
None
|
upc
|
str | None
|
UPC barcode. |
None
|
q
|
str | None
|
Full text search on title and/or console. Only the best match is returned. |
None
|
Returns:
| Type | Description |
|---|---|
ProductResponse
|
The matching product. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If not exactly one of |
APIError
|
If the API returns an error. |
products(q)
Search for products by title and/or console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
str
|
Full text search on title and/or console. Surrounding whitespace is stripped. |
required |
Returns:
| Type | Description |
|---|---|
ProductsResponse
|
Up to 20 matching products. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offers(params)
List marketplace offers matching the given filters.
The same request can be made at most once every 5 minutes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
OffersRequestParams
|
Offer filters. Only |
required |
Returns:
| Type | Description |
|---|---|
OffersResponse
|
The matching offers. |
Raises:
| Type | Description |
|---|---|
APIError
|
If the API returns an error. |
offer_details(offer_id)
Get the full details of one marketplace offer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
Returns:
| Type | Description |
|---|---|
OfferDetailsResponse
|
The offer, including the buyer's shipping details once it has sold. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offer_publish(params)
Publish a new marketplace offer, or edit an existing one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
OfferPublishRequestParams
|
The offer to publish. Set |
required |
Returns:
| Type | Description |
|---|---|
OfferPublishResponse
|
The published offer. |
Raises:
| Type | Description |
|---|---|
APIError
|
If the API returns an error. |
offer_feedback(offer_id, rating, comment=None)
Leave feedback on a marketplace offer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
rating
|
Rating
|
How the transaction went. |
required |
comment
|
str | None
|
Text explaining the rating. |
None
|
Returns:
| Type | Description |
|---|---|
OfferFeedbackResponse
|
The feedback left. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offer_ship(offer_id, tracking_number=None)
Mark a sold marketplace offer as shipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
tracking_number
|
str | None
|
USPS, FedEx, UPS, or other tracking number. A valid one can earn positive feedback if the buyer leaves none. |
None
|
Returns:
| Type | Description |
|---|---|
OfferShipResponse
|
The shipped offer. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offer_end(offer_id)
End a marketplace offer so it can no longer be purchased.
For a collection item, this removes it from the collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
Returns:
| Type | Description |
|---|---|
OfferEndResponse
|
The ended offer. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offer_refund(offer_id)
Refund a purchased marketplace offer.
Payment is returned immediately from the seller's PayPal account to the buyer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
Returns:
| Type | Description |
|---|---|
OfferRefundResponse
|
The refunded offer. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
pypricecharting.asyncpricecharting.AsyncPriceCharting
Asynchronous PriceCharting API client.
Reuse one client for all requests and close it when done (async with or aclose()).
TOKEN_KEY = 'PRICECHARTING_TOKEN'
class-attribute
instance-attribute
Environment variable the token is read from when none is passed.
__init__(token=None, base_url=BASE_URL, transport=None)
Create a client authenticated with a PriceCharting API token.
The token is redacted from httpx2 request logs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str | None
|
The 40-character PriceCharting API token. If omitted, it is read from the
|
None
|
base_url
|
str
|
API base URL. Override it to use a mock server. |
BASE_URL
|
transport
|
AsyncBaseTransport | None
|
Custom |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the token is missing or not 40 characters. |
aclose()
async
Close the underlying HTTP client.
__aenter__()
async
Enter the async context and return the client.
__aexit__(exc_type, exc_value, traceback)
async
Close the underlying HTTP client on exit.
product(id=None, upc=None, q=None)
async
Get a single product by exactly one of id, upc, or q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str | None
|
PriceCharting product ID. |
None
|
upc
|
str | None
|
UPC barcode. |
None
|
q
|
str | None
|
Full text search on title and/or console. Only the best match is returned. |
None
|
Returns:
| Type | Description |
|---|---|
ProductResponse
|
The matching product. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If not exactly one of |
APIError
|
If the API returns an error. |
products(q)
async
Search for products by title and/or console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
str
|
Full text search on title and/or console. Surrounding whitespace is stripped. |
required |
Returns:
| Type | Description |
|---|---|
ProductsResponse
|
Up to 20 matching products. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offers(params)
async
List marketplace offers matching the given filters.
The same request can be made at most once every 5 minutes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
OffersRequestParams
|
Offer filters. Only |
required |
Returns:
| Type | Description |
|---|---|
OffersResponse
|
The matching offers. |
Raises:
| Type | Description |
|---|---|
APIError
|
If the API returns an error. |
offer_details(offer_id)
async
Get the full details of one marketplace offer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
Returns:
| Type | Description |
|---|---|
OfferDetailsResponse
|
The offer, including the buyer's shipping details once it has sold. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offer_publish(params)
async
Publish a new marketplace offer, or edit an existing one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
OfferPublishRequestParams
|
The offer to publish. Set |
required |
Returns:
| Type | Description |
|---|---|
OfferPublishResponse
|
The published offer. |
Raises:
| Type | Description |
|---|---|
APIError
|
If the API returns an error. |
offer_feedback(offer_id, rating, comment=None)
async
Leave feedback on a marketplace offer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
rating
|
Rating
|
How the transaction went. |
required |
comment
|
str | None
|
Text explaining the rating. |
None
|
Returns:
| Type | Description |
|---|---|
OfferFeedbackResponse
|
The feedback left. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offer_ship(offer_id, tracking_number=None)
async
Mark a sold marketplace offer as shipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
tracking_number
|
str | None
|
USPS, FedEx, UPS, or other tracking number. A valid one can earn positive feedback if the buyer leaves none. |
None
|
Returns:
| Type | Description |
|---|---|
OfferShipResponse
|
The shipped offer. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offer_end(offer_id)
async
End a marketplace offer so it can no longer be purchased.
For a collection item, this removes it from the collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
Returns:
| Type | Description |
|---|---|
OfferEndResponse
|
The ended offer. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |
offer_refund(offer_id)
async
Refund a purchased marketplace offer.
Payment is returned immediately from the seller's PayPal account to the buyer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offer_id
|
str
|
The offer ID. Surrounding whitespace is stripped. |
required |
Returns:
| Type | Description |
|---|---|
OfferRefundResponse
|
The refunded offer. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If |
APIError
|
If the API returns an error. |