Selling on TCGplayer with product ids
Cardspine is built around TCGplayer product ids. It gives you the id and the printing for what you stock; it does not post listings for you. Use the ids to build the files and products you list from.
Run the JavaScript on your server, for example in Node.js. The API sends no CORS headers for other origins, so a browser page cannot call it, and your key has to stay out of the browser anyway.
Look up what you stock
Send your TCGplayer product ids 100 at a time to GET /api/v1/products/tcgplayer?ids=. A batch is one request, and ids that match no product come back in missing. Do not have an id for an item yet? Find it with search and keep it.
curl -G "https://api.cardspine.com/api/v1/products/tcgplayer" \
-H "X-Api-Key: $CARDSPINE_KEY" \
--data-urlencode "ids=517045,246723,454666"Map each item to its id and printing
Each item carries tcgplayerProductId, the name, the set code and the number as printed. printings lists the finishes it is sold in, as TCGplayer names them; it is empty until they have been read for that set.
const rows = [...found.values()].flatMap((p) => {
const finishes = p.printings.length ? p.printings.map((x) => x.printing) : ['']
return finishes.map((printing) => ({
id: p.tcgplayerProductId,
name: p.name,
set: p.set.code,
number: p.number,
printing,
quantity: stock.get(p.tcgplayerProductId),
}))
})Export a file for TCGplayer’s bulk listing tools
Write the rows to a CSV and rename the columns to match the template TCGplayer gives your seller account. The product id column is the one that has to be exact.
const quote = (v) => '"' + String(v ?? '').replaceAll('"', '""') + '"'
const columns = ['id', 'name', 'set', 'number', 'printing', 'quantity']
const csv = [columns.join(','), ...rows.map((r) => columns.map((c) => quote(r[c])).join(','))].join('\n')Keep the same ids in Shopify
Store the id in a product metafield, so TCGplayer, Shopify and your own site all point at the same product.
mutation {
metafieldsSet(metafields: [{
ownerId: "gid://shopify/Product/1234567890",
namespace: "cardspine",
key: "tcgplayer_product_id",
type: "number_integer",
value: "517045"
}]) {
metafields { id }
userErrors { message }
}
}