Guides
Post and manage listings
Post, change, pause and close your company's listings, with photos.
Posting through the API runs the same checks as the posting form on the site. A refusal answers 422 invalid with the form's own words, for example "Pick one of the units listed for Soil and fill."
1. Read the category
curl -H "X-API-Key: ssk_YOUR_KEY" "https://dev.siteswap.pro/api/v1/catalog/categories?marketplace=materials"
curl -H "X-API-Key: ssk_YOUR_KEY" https://dev.siteswap.pro/api/v1/catalog/categories/3The category lists its units, its materials or types, and its questions (fields), with which are required on an offered listing.
2. Post
curl -X POST "https://dev.siteswap.pro/api/v1/listings" \
-H "Authorization: Bearer ssk_YOUR_KEY" -H "Content-Type: application/json" \
-d '{"marketplace":"materials","kind":"have","category_id":"5","material_id":"21","quantity":12,"unit":"pallets","quantity_basis":"measured","price_model":"fixed","price":40,"zip":"01801","photo_urls":["https://photos.yourcompany.com/pavers-1.jpg"]}'const res = await fetch("https://dev.siteswap.pro/api/v1/listings", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.SITESWAP_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ marketplace: "materials", kind: "have", category_id: "5", material_id: "21", quantity: 12, unit: "pallets",
quantity_basis: "measured", price_model: "fixed", price: 40, zip: "01801" }),
});
const json = await res.json();
if (!res.ok) throw new Error(json.error.code + ": " + json.error.message);
console.log(json.data.url);import os, requests
r = requests.post("https://dev.siteswap.pro/api/v1/listings", headers={"Authorization": "Bearer " + os.environ["SITESWAP_KEY"]},
json={"marketplace": "materials", "kind": "have", "category_id": "5", "material_id": "21", "quantity": 12,
"unit": "pallets", "quantity_basis": "measured", "price_model": "fixed", "price": 40, "zip": "01801"})
print(r.status_code, r.json())- Send the answers to the category's questions under
fields, by key. Soil and fill offered needs the soil statement too: its fields go underfieldswith the names of the posting form, withack: true. - Photos: up to 8 by https address, 15 MB each. SiteSwap downloads each once and stores it; the address is not kept. Addresses on private networks are refused.
- The ZIP places the listing and is never shown.
3. Change, pause or close
PUT /listings/{id} replaces the listing with what you send: send the whole listing, as you would post it. The marketplace and the kind cannot change, and the quantity cannot go below what is promised to accepted offers.
curl -X POST "https://dev.siteswap.pro/api/v1/listings/1042/status" -H "X-API-Key: ssk_YOUR_KEY" -H "Content-Type: application/json" -d '{"status":"paused"}'active, paused and closed. Closing is for good.
SiteSwap API v1Support