How can we help?

Stape store

Ivanna
Ivanna
  • Updated

Stape store is a scalable NoSQL database that provides near-instantaneous read/write and sync functions of data in an sGTM container.

 

We have developed three custom templates to work with  Stape Store:

  • Stape store writer, tag to write data to the Stape store:

https://github.com/stape-io/stape-store-writer-tag

  • Stape lookup variable, for retrieving data from the database

https://github.com/stape-io/stape-store-lookup-variable

  • Stape restore variable, can write and get data at the same time

https://github.com/stape-io/stape-store-restore-variable

 

This advancement brings two significant benefits to our users:

  • Cost-Efficiency: the Stape Store is available for users with a Business or higher plan at no additional cost.
  • Ease of Use: it requires no additional configuration or authorization, dramatically simplifying the data storage process.

1mb - maximum size of one document. Now, you can store your authorization keys and other useful data for tracking in just a few clicks.

 

Stape store API

Base URL

The base URL for all API requests is:

https://{CONTAINER_DOMAIN}/stape-api/{CONTAINER_KEY}/v1/store


Both CONTAINER_DOMAIN and CONTAINER_KEY could be retrieved from the request headers. See example below:

 

function getBaseUrl() {

   const containerIdentifier = getRequestHeader('x-gtm-identifier');

   const defaultDomain = getRequestHeader('x-gtm-default-domain');

   const containerApiKey = getRequestHeader('x-gtm-api-key');

 

   return (

     'https://' +

     enc(containerIdentifier) +

     '.' +

     enc(defaultDomain) +

     '/stape-api/' +

     enc(containerApiKey) +

     '/v1/store'

   );

}

 

Endpoints

Add / update documents

This endpoint is used to create or overwrite a single document.

If the document does not exist, it will be created. If the document does exist, its contents will be overwritten with the newly provided data. If you want to merge data into an existing document instead of overwriting it, use the PATCH method instead of PUT.

Endpoint

PUT /v1/store/{key}

PATCH /v1/store/{key}


Request

Content-Type: application/json

 

Parameter Type Description
key string The identifier for the document.
Should match the regex ^[a-zA-Z0-9_$%@+=.\/\-]+$

 

The request body should contain JSON-structured data to add or update the document.

{

 "key-string": "value",

 "key-array": [

   "item1",

   "item2"

 ],

 "key-object": {

   "key1": "1",

   "key2": 2

 }

}

 

Example

 

PUT /v1/store/uniquekey

Content-Type: application/json

{

 "name": "John Doe",

 "age": 30,

 "identifiers": [

     123456,

     "john@doe.com"

 ]

}

 

Get documents

This endpoint is used to retrieve data for the document identified by the key parameter.

GET /v1/store/{key}

 

Parameter Type Description
key string The identifier for the document.
Should match the regex ^[a-zA-Z0-9_$%@+=.\/\-]+$

Example

GET /v1/store/uniquekey

 

Delete documents

This endpoint is used to delete the document identified by the key parameter.

DELETE /v1/store/{key}

 

Parameter Type Description
key string The identifier for the document.
Should match the regex ^[a-zA-Z0-9_$%@+=.\/\-]+$

Example

DELETE /v1/store/uniquekey

 

List documents

This endpoint lists and filters documents based on the specified criteria.

 

POST /v1/store

 

Request Headers:

Content-Type: application/json

 

Body parameters:

 

Parameter Type Description
key string Optional. Filter by document key. Should match the regex ^[a-zA-Z0-9_$%@+=.\/\-]+$
data array[] Optional. Filter by document data using a three-item array containing:
1. Name of the document data filed
2. One of the supported query operators
3. Value used for quering
limit integer Optional. Limit the number of documents per page. Default is 10.
skip integer Optional. Skip a certain number of documents (pagination).


Query operators:

  • equal - Equal. Checks if the specified field is equal to the provided value.
  • not-equal - Not Equal. Checks if the specified field is not equal to the provided value.
  • lt -  Less Than. Checks if the specified field is less than the provided value.
  • lte -  Less Than or Equal. Checks if the specified field is less than or equal to the provided value.
  • gt - Greater Than. Checks if the specified field is greater than the provided value.
  • gte - Greater Than or Equal. Checks if the specified field is greater than or equal to the provided value.
  • array-contains - Array Contains. Checks if the specified field, treated as an array, contains the provided value.
  • array-contains-any - Array Contains Any. Checks if the specified field, treated as an array, contains any of the provided values.
  • in - In. Checks if the specified field value is in the list of provided values.
  • not-in - Not In. Checks if the specified field value is not in the list of provided values.
  • contains - Contains. Checks if the specified field value contains the provided value (string search).
  • not-contains - Not Contains. Checks if the specified field value does not contain the provided value (string search).

Example

POST /v1/store

Content-Type: application/json

{

 "data" : [

   [

       "age",

       "gt",

       25

   ],

   [

       "identifiers",

       "array-contains-any",

       ["john@doe.com", "john+1@doe.com"]

   ]

 ],

 "limit" : 1

}

Was this article helpful?

1 out of 2 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.