Introduction

StorePI is a free, open-source API that was created for use in e-commerce prototyping, Front-End Developer talent evaluations, and anything else you can think of. The API and accompanying documentation was built with Next.js, Typescript, Tailwind CSS, Supabase, and Vercel.

It provides resources such as products, reviews, users, carts, purchases, and more. Endpoints are provided to perform CRUD operations on each of these resources, both as an anonymous user and as an authenticated user.

StorePI demo

If you're the Postman type, you can find that version of the documentation here.

A default dataset is provided with this API. It consists of 19 users (each with a cart and wishlist), 50 products, 6 categories, 44 brands, 160 product reviews, and 50 purchases.

That said, you do have the ability to interact with the database and persist your custom data with select resources. Notably, You may sign up as a new user and perform any of the following actions as your new user:

  • Log in
  • Modify your profile
  • Create/edit reviews
  • Add/remove cart items
  • Add/remove wishlist items
  • Create a new purchase

While creating your own user is recommended, you may also perform any of the above actions as one of the users from the original dataset. When doing so, the endpoint will still respond as if the request were successful, but your data will not be persisted. See logging in for information on how to authenticate as one of these users.

Cross-origin resource sharing is enabled for all incoming requests.

Certain requests require a JWT for authorization. Requests that do require the token are indicated as such by the icon. As a general rule, any request that is reading or writing to a current user's resources will require the bearer token:

headers: { Authorization: "Bearer {your access token}" }

A bearer token can be obtained via the log in endpoint, where it will be returned in the request body and be valid for 12 hours.

The following query parameters can optionally be appended to all GET requests.

ParameterDescriptionExample
sortSort the query results by one or more fields (comma-delimited). Use - to indicate descending order.?sort=-sale_price,-regular_price
fieldsFilter the query results to one or more specific fields (comma-delimited).?fields=name,sale_price
limitLimit the query results. Defaults to 20.?limit=10
offsetPaginate the query results. Defaults to 0.?offset=2

Each GET response will contain a count value that indicates the total number of items that match the given query. If the limit or offset parameter was passed, it will also contain a nextOffset value.

All fields of a given resource are valid for applying filters to a query. A full list of these fields can be found on each resource's page. The following operators are supported for GET requests:

ParameterDescriptionExample
[field]=[value]Standard equality - the value must match the field's value exactly.?in_stock=true
[field]_greater_thanThe value must be greater than the field's value.?sale_price_greater_than=100
[field]_greater_than_or_equal_toThe value must be greater than or equal to the field's value.?sale_price_greater_than_or_equal_to=100
[field]_less_thanThe value must be less than the field's value.?sale_price_less_than=200
[field]_less_than_or_equal_toThe value must be less than or equal to the field's value.?sale_price_less_than_or_equal_to=200
[field]=[value1],[value2]Check if the field's value is equal to any of the given values.?category_id=1,2

Under the hood, StorePI makes use of PostgREST to provide an intuitive REST API. However, if you prefer to skip a layer and access the data using their syntax, you can do so by making use of the following variables:

VariableValue
PROJECT_REF

wkzyrrbzyyljtvkayjyn

API_KEY

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndrenlycmJ6eXlsanR2a2F5anluIiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODk4MjM5NTYsImV4cCI6MjAwNTM5OTk1Nn0.dxSC_1fFOHxE5xPLfQTuzp5raKuPjoE1a9ab6vZn8KY

Also thanks to its reliance on Supabase, StorePI comes with pg_graphql - a PostgreSQL extension that enables querying the database with GraphQL using a single SQL function. Reference the variables in the PostgREST section to get started.

You may also download the GraphiQL snippet to explore the GraphQL schema in-browser