Pfapi plugin provides fast, secure, configurable, and scalable API services for e-commerce web apps.
Pfapi plugin uses pfapi-core library to provide fast, secure, configurable, and scalable API services for e-commerce web apps.
Pfapi plugin is a Strapi version 4 plugin. It requires the in-memory data store Redis. Please refer to Redis getting started to install redis server for your environment.
yarn add strapi-plugin-pfapi
OR
npm install strapi-plugin-pfapi
Click to see full documentation
With the world cities test data set provided by plugin strapi-plugin-pfapi-data, we can run API calls to demonstrate the idea.
Please refer to Redis getting started to install redis server on your local computer.
yarn create strapi-app strapi-pfapi-app --quickstart
OR
npx create-strapi-app strapi-pfapi-app --quickstart
After creating and logging into your Strapi account from the browser, stop the strapi server.
You don't have to install strapi-plugin-pfapi-data for your production.
strapi-plugin-pfapi-data provides a test data set for demo and test
cd strapi-pfapi-app
yarn add strapi-plugin-pfapi strapi-plugin-pfapi-data
yarn develop
OR
npm install strapi-plugin-pfapi strapi-plugin-pfapi-data
npm run develop
get your api_key from:
Please replace Pfapi-Demo-XXXXXXXX with Pfapi-Demo for the convenience of using links posted below.
A role with name PfapiDemo is installed in the above steps.
Go to Settings > USERS & PERMISSIONS PLUGIN > Roles:
http://localhost:1337/admin/settings/users-permissions/roles
click on PfapiDemo,
Under Permissions > World-city
assign find and findOne permissions to PfapiDemo and click save.
OK, we are ready to run demos.
http://localhost:1337/pfapi/world-cities?api_key=Pfapi-Demo
http://localhost:1337/pfapi/world-cities/2148?api_key=Pfapi-Demo
handle configs are defined in PfapiHandle.
/pfapi
http://localhost:1337/pfapi/northern-cities?api_key=Pfapi-Demo
http://localhost:1337/pfapi/northern-cities/2148?api_key=Pfapi-Demo
strapi api parameters
http://localhost:1337/pfapi/northern-cities?filters[iso3]=USA&api_key=Pfapi-Demo
config data defined in PfapiHandles for handle northern-city:
http://localhost:1337/pfapi/northern-city/Anchorage?api_key=Pfapi-Demo
goto http://localhost:1337/admin/content-manager/collectionType/api::world-city.world-city/2148
make some change, for example: change the population from 288000 to 288001
check APIs:
http://localhost:1337/pfapi/northern-cities/2148?api_key=Pfapi-Demo
http://localhost:1337/pfapi/northern-city/Anchorage?api_key=Pfapi-Demo
to see if the cached data was evicted and updated
goto http://localhost:1337/admin/content-manager/collectionType/plugin::pfapi.pfapi-handle/1
make some changes, for example: add or remove country to the fields array
check APIs:
http://localhost:1337/pfapi/northern-cities/2148?api_key=Pfapi-Demo
http://localhost:1337/pfapi/northern-cities/2148?api_key=Pfapi-Demo
npm install strapi-plugin-pfapi
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.