Simlar to the GraphQL concept of only returning what is required. Wappi allows you to include or exclude fields that will be normally returned by the endpoint.
WAPPI does this filtering on the backed, so it's securly hidden on your server.
To include or exlcude data, it has to be send through in the body data.
Latency is the slowest part of an API, especially if your server is not in the same country as the users device.
Reducing the size of data packets to be only what you need will dramatically speed up the response time.
Lets say that you have a endpoint (GetAllProductData) that returns all the data for a product, including sub products, sizes, all the price data, history, reviews, etc..
Lets say the full response is 1MB of data.
However on the front end, you only want to show the product name, price and availability.
With WAPPI, you can include only these 3 fields. Making the response only 4KB.
This reduction would remove 99% of the data size and make the API call around 200X faster.
You can also Exclude data that you don't want your backend to send through to the frontend.
As an example: you have a private API that only connect your backend to your frontend (Meaning no external person has access to your API).
You have a generic endpoint, that returns all the product data, even your profit margin. You use this endpoint for internal admin features, but also for your public frontend.
But you don't want users to see the profit margin.
Just exclude this data from the response and your profit margin will never be returned.
This saves you from doubling up on endpoints, and allows you to only show data you want to show.
Structure:
1{
2 ...
3 results: { // Default is "result"
4 name: "customResultsName",
5 include: [
6 {
7 name: "camelCaseCustomName",
8 key: "keyNameToInclude"
9 }
10 ],
11 },
12}Example:
1{
2 ...
3 result: {
4 name: "basicProductData",
5 include: [
6 {
7 name: "productName",
8 key: "name"
9 },
10 {
11 name: "productPrice",
12 key: "price"
13 },
14 {
15 name: "productAvailable",
16 key: "availablity"
17 }
18 ],
19 },
20}This would return:
1{
2 basicProductData: {
3 productName: "Awesome Product Name",
4 productPrice: 123.32,
5 productAvailable: true,
6 },
7}Structure:
1{
2 ...
3 results: { // Default is "result"
4 name: "customResultsName",
5 exclude: [
6 {
7 key: "keyNameToExclude"
8 }
9 ]
10 },
11}Example:
1{
2 ...
3 result: {
4 name: "publicProductData",
5 exclude: [
6 {
7 key: "profitMargin"
8 },
9 ],
10 },
11}This would return:
1{
2 publicProductData: {
3 id: '1kjh132',
4 price: 123.45.
5 name: "Awesome Product Name"
6 ...
7 // All product data. Execpt: profitMargin
8 },
9}