Hello everyone,
I am not yet very familiar with the technology of WIX and have a question about API keys that are created in Wix (/account/api-keys), as the documentation and the REST assistant of the documentation provide contradictory information:
Is it possible or is it not (yet) possible to send requests to eCommerce endpoints such as https://www.wixapis.com/ecom/v1/orders/search using a created API key?
The documentation and the AI assistant largely state that this is possible and that no OAuth or app development within Wix is necessary if an API key is used. However, in a simple practical test with a simple PHP script, it seems to me that no valid request to eCommerce endpoints (or any endpoints at all) is possible. I also saw in the documentation for some endpoints that API keys are only available to BETA testers so far. And the AI assistant stated one time that the required authentification for search-orders requests as a Wix app or Wix user is NOT fulfilled by using a API key.
I would be very happy to receive a clear answer in the sense of ‘Yes, you can use API keys for eCommerce’ or ‘No, you cannot use API keys for eCommerce requests’.
OAuth is required for any calls in user-level API’s or Wix Apps, API key is for site level and account level calls. SO it’s not about ecommerce per se - it depends on what you are doing. In the REST API api key docs there is an example getting all the products at the site level using the API key strategy that may be useful to take a look at.
Here’s the documentation to read more REST Docs
If you are using the Account Level or Site Level API Keys, then make sure to provide the account / site ID along with the Authorization
as shown in this example:
First of all, thank you very much for your quick answers!
I interpret your answers as a clear: Yes, it is technically theoretically possible to call eCommerce endpoints with an API key.
And I assume the example mentioned by @amandam can be found at the bottom of:
The answer to the question of why no request to an eCommerce endpoint has yet been recognised as valid is something I’ll have to research further.
The aim is to use an API request to retrieve the orders (from the last 24 hours) from the Wix webshop and process their data in another system. The situation and technical starting point is somewhat complicated, because not only am I not yet familiar with Wix, I am also actually a service provider for a partner of the webshop operator and am therefore not familiar with the circumstances or the status of the webshop (and as a further difficulty, this information is actually not available unless I research it directly in the Wix console https://manage.wix.com/). As you can see, I’m going to have fun programming blindly and into the blue.
Yes - that sounds like a site level call to me.
Given you are not the site owner, i’m wondering if there is something else blocking you.
We do have a channel dedicated to headless in our Discord server that the team manages which may be a good place to put this question as well. Wix Studio Community
@amandam, just curious if this rather unconventional approach would work in this case?
How about querying the “Stores/Orders” collection using elevated permissions and then returning the info as response to an http-function?
You could certainly create an http-function to expose this (or any data) from a Wix site but given that this sounds like OP is creating an external system or app, I would advice headless is a better route here. An http-function with elevated permissions to perform this query would not be secure out of the box as well and you would have to do more work to secure this.
Possible yes. But the requirements will drive what solution is best for sure.
1 Like
Yes, it’s about an external (web) system that needs and should process the order data.
I want to keep access to this data as direct and simple as possible. So my hope is that the data can be retrieved using an API key, a http request and eCommerce. In other words, preferably without the need for customizations, apps, plugins, etc. within the Wix webshop project. Because this is a customer’s customer’s project, I currently have very limited options (and information) and even fewer later on.
I can also already confirm that the example from the documentation works on the endpoint https://www.wixapis.com/stores/v1/products/query.
Now I wanted to deduce from this why eCommerce and the retrieval of order data has failed so far and whether the entry with ‘Authentication: You can only call this method when authenticated as a Wix app or Wix user identity’ is also in the documentation for the endpoint products/query. But it seems to me that there is no entry for the products/query endpoint in the documentation under Business Solutions → Stores. In addition, ‘stores-reader/v1/products’ is probably more often specified here instead of ‘stores/v1/products’.
// Edit: Example of documentation only worked as long as I forgot to add the body-data to the request. Already tried several different ways of syntax for the example code but looks like there is some difficulty or issue with that, response still ‘[message] => Unexpected value for StringValue [details] => Array ( )’
That error implies the call requires OAuth, so I would test with that. I would still recommend posting directly in the headless channel in Discord for further assistance Wix Studio Community
If you beleive you are encountering a bug, this will show how to start a ticket Wix Studio - How to report a bug