Strapi plugin logo for Pfapi

Pfapi

Pfapi plugin provides fast, secure, configurable, and scalable API services for e-commerce web apps.

tests release

Strapi plugin pfapi

Pfapi plugin uses pfapi-core library to provide fast, secure, configurable, and scalable API services for e-commerce web apps.

  • Pfapi uses local and Redis caches to achieve single-digit milliseconds on average API response time.
  • IP unlimited / blocked lists, Rate limits and activities log are accessible through the admin panel.
  • API handles for detail and list views are powered by highly configurable components dynamic zone.
  • Configurable filters enable user-friendly UX for users to find what they are looking for.
  • Production environment that runs multiple Strapi servers and Redis cluster is supported and tested.

Requirements

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.

How to install

yarn add strapi-plugin-pfapi

OR

npm install strapi-plugin-pfapi

Click to see full documentation

Setup Demonstration

With the world cities test data set provided by plugin strapi-plugin-pfapi-data, we can run API calls to demonstrate the idea.

step 1 install Redis server

Please refer to Redis getting started to install redis server on your local computer.

step 2 create strapi app

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.

step 3 install plugins

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

step 4 setup api_key and permissions

get your api_key from:

http://localhost:1337/admin/content-manager/collectionType/plugin::pfapi.pfapi-key?page=1&pageSize=10&sort=key:ASC

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:

Setup PfapiDemo role

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.

step 5 demos

a) tests content-type name world-cities as path variable

http://localhost:1337/pfapi/world-cities?api_key=Pfapi-Demo

http://localhost:1337/pfapi/world-cities/2148?api_key=Pfapi-Demo

b) tests config handle northern-cities as path variable

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

c) tests with config handle northern-city with id_field is name

config data defined in PfapiHandles for handle northern-city:

http://localhost:1337/pfapi/northern-city/Anchorage?api_key=Pfapi-Demo

d) test data update

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

e) test config update

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

Install now

npm install strapi-plugin-pfapi

STATS

8 GitHub stars7 weekly downloads

Last updated

724 days ago

Strapi Version

Unavailable

Author

github profile image for Sam Wen
Sam Wen

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.