All API URLs start with https://[mystorename.com]/api/v1/
, where [mystorename.com]
is the domain name of your Americommerce Spark Pay Online Stores store. All requests require an access token, which can be obtained either through the OAuth 2 process or the admin console (there is one exception, as noted at the end of this section). The access token is passed in as a special header called X-AC-Auth-Token
.
In curl, a simple request for the product list would look like this:
curl -H 'X-AC-Auth-Token: [MyAccessToken]' https://[mystorename.com]/api/v1/products.json
In this example, [MyAccessToken]
would be replaced with the actual access token you obtained from the site. Similarly, a request to create a product could look like this. Take note of the Content-Type
and request body here:
curl -H 'Content-Type: application/json' \
-H 'X-AC-Auth-Token: [MyAccessToken]' \
-d '{ \
"item_name": "My test product", \
"item_number": "mytestproduct", \
"product_status_id": 1, \
"primary_category_id": 1
}' \
https://[mystorename.com]/api/v1/products.json
While logged into the admin console of your site, you can view the results of any GET requests from your browser, assuming you have access to the admin area in question. Since your session is already authenticated, you do not need the access token for this.