This guide will show you how to setup a PrestaShop instance with the ps_apiresources module replaced with a Git folder and linked to your fork so you can add new endpoints.
It is based on docker so a maximum of people can follow it regardless of their environment, but you can setup your environment differently and locally if you prefer.
ps_apiresources module folder (installed by composer) with a Git folder, so you can create pull requests.We base this guide on the 9.0.x branch but you can use a more recent branch if you want.
git clone -b 9.0.x [email protected]:PrestaShop/PrestaShop.git prestashop-90x
cd prestashop-90x
make docker-start
# The installation runs in background and takes a few minutes, you can run this command to see its progress
make docker-logs
# Once you see the message "Starting web server now" you're good to go
You should now be able to access your PrestaShop installation
cd modules
rm -fR ps_apiresources
git clone [email protected]:PrestaShop/ps_apiresources.git
cd ps_apiresources
# You need to fork the repository so you can add your custom fork remote, you will push your branch on it to create the PR
git remote add fork git clone [email protected]:{myfork}/ps_apiresources.git
git fetch fork
# Go back to the root and clear the cache
cd ../..
make cc
make docker-sh # Open a shell in the docker
./bin/console prestashop:api-client create test --all-scopes --name='Test client' --description='Test client with all scopes' --timeout=3600 --secret=60b3045648285513cae71350b697dce3
# You can now exit from docker shell
Always use auto generated secret
The secret provided here should only be used for development, it is suggested here for convenience so developers have a common value when they discuss, but this should never be done in production.
You should not pick your secret yourself and should let PrestaShop generate it automatically for you (the CLI option is optional, remove it and the secret is autogenerated).
Never use all scopes
The security of your Admin API rely on having limited API Clients with limited access, only give your Client the bare minimum scopes they need for their usage.
Each integration with an external service should rely on a dedicated API Client that has its dedicated scopes useful for this integration only.
Go to admin http://localhost:8001/admin-dev/configure/advanced/admin-api (login and ignore the token protection)
You should see a Test client in the list, edit it to check it has all the scopes authorized

By default, the Admin API must be used with HTTPs protocol, in development it’s not required though but you need to disable this protection.
In the configuration uncheck the “Force security in debug mode” and save the configuration

Now go to Swagger, there is a link in the Admin API index in the BO

(or go to http://localhost:8001/admin-dev/configure/advanced/admin-api/docs.html)
Click on Authorize, and use the credentials of your Api Client

Click on Authorize button at the bottom
You can now use Swagger as your client to call the Admin API, you can also use Postman or similar tools if you prefer.