Skip to content
Gallery
Envision
Share
Explore
Docs

Backend Apis Documentation

SETUP

pip install -r requirements.txt
run server : flask --app run
get keyfile.json and place it in home directory
go to and change path to keyfile
go to uncomment os.environ line if commented
set GOOGLE_APPLICATION_CREDENTIALS environment variable to keyfile path

GUNICORN SETTING

GUNICORN advises between 2-4 workers per core The --threads option defines how many threads a single worker can use current configuration is “–workers 1 --threads 16”

API Documentation

This documentation provides information on how to use the API for the client-side developer.

Verify-Payment

Endpoint: /verify-payment
Method: POST
Description: This endpoint receives a -payment-token (apple receipt) and fcm_token in body -and debuggindMode (true/false) to check for debugging environment (here original_transaction_id mst be 0)
Verifies payment token from apple.
check if a user already exists with that token using the original-transaction-id
if a new subscription then create a new user
else get the existing user and update it in db with new updated info if any
create a new jwt token for user and return it
if invalid payment-token then error with 400 status code is returned
verifies fcm_token if sent and stores in user document in db Note: fcm token is optional
Example Request body:
{
"payment_token": {
"expires_date" : "2024-12-16 14:59:45 Etc/GMT",
"expires_date_ms" : "1702738785000",
"original_transaction_id" : "2001000489270504",
"product_id" : "com.envision.weekly",
"transaction_id" : "2001000489270504"
},
"fcm_token":"dvJampKbh4lrPIEVOgx6e5:APA91bGlE_OGroJdpW6LOTPsDoWZsx2PyL57MhvhCEM8MmaT1g6nuTFDW0s3PUa5MEv3BlyCjofcbcSa6nL3TWmorPrc5qjjiL1d0WnriVOs-IRjCe6Fb4TSnUqn9tjtCAyFY15vbqwB"
}
Example response:
if a user with given original_transaction_id already present
{
"jwt_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNWVlMGM5ZDItOTkxNy00ZTJkLWJjNWEtZTIxODZhODBiMThlIiwiaWF0IjoxNzAyMDQ5NTMxLCJleHAiOjE3MDI2NTQzMzF9.LHEQGIELpXt4GuoiRJe14dGPZunCxJ2PPd32q3Ydppk",
"userExists": True
}


if new user
{
"jwt_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNWVlMGM5ZDItOTkxNy00ZTJkLWJjNWEtZTIxODZhODBiMThlIiwiaWF0IjoxNzAyMDQ5NTMxLCJleHAiOjE3MDI2NTQzMzF9.LHEQGIELpXt4GuoiRJe14dGPZunCxJ2PPd32q3Ydppk",
"userExists": False
}
Example response: for expired subscription
{
"jwt_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNWVlMGM5ZDItOTkxNy00ZTJkLWJjNWEtZTIxODZhODBiMThlIiwiaWF0IjoxNzAyMDQ5NTMxLCJleHAiOjE3MDI2NTQzMzF9.LHEQGIELpXt4GuoiRJe14dGPZunCxJ2PPd32q3Ydppk",
"subscriptionStatus": "subscription_expired",
"userExists": True
}
List of cases where verify payement returns 400 bad request errors
if payment_tokenis not sent in request body
if payment_type is not sent or is not equal to apple
if fcm_token is sent but is still invalid
if any of required values inside payment_token is missing, these required values are "expires_date", "expires_date_ms", "original_transaction_id", "product_id", "transaction_id", if any one is missing backend responds with 400 bad request error
if the values inside payment_token are not the same as values received from apple getTransactionInfo api called for transaction_id

packs-info

Endpoint /packs-info
Method: GET
Description: This api returns all the packs names, display name and their thumbnail_urls for our app, also returns the list of featured packs with their thumbnails specific to be sown when they are featured
Database Format
-db path for common configs for all packs /CONFIGS/prompt_configs
-db path for pack specific configs /CONFIGS/prompt_configs/packs/pack_name
-For Featured packs
display-name(string)
is_active(boolean)
featured(boolean)
featured_thumbnail(string)
num_images_per_prompt(number)
num_prompts(number)
secondary-thumbnail-images(array)
thumbnail(array)
-For Simple Packs
display-name(string)
is_active(boolean)
num_images_per_prompt(number)
num_prompts(number)
secondary-thumbnail-images(array)
thumbnail(array)
is_active field is used for keeping tabs on which packs are current(active) or obsolete(inactive) adn not to be shown in explore screen.
Example Response:
{
"featuredPacks": [
{
"display_name": "Neonpunk",
"featured_thumbnail": "https://storage.googleapis.com/jetrr-public/single-pack-images-v1/neon_1.png",
"pack_name": "neon",
"thumbnail": ["https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",
"https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",
"https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",],

"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/neon_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/neon_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/neon_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/neon_4.png"
]
},
{
"display_name": "GTA",
"featured_thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Gta.png",
"pack_name": "gta",
"thumbnail": ["https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",
"https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",
"https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",],
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/gta-1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/gta-2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/gta-3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/gta-4.png"
]
},
{
"display_name": "Historical & Renaissance",
"featured_thumbnail": "https://storage.googleapis.com/jetrr-public/single-pack-images-v1/historical_1.png",
"pack_name": "historical",
"thumbnail": ["https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",
"https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",
"https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",],
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/historical_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/historical_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/historical_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/historical_4.png"
]
},
{
"display_name": "Fashion",
"featured_thumbnail": "https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fashion_1.png",
"pack_name": "fashion",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Fashion.png",
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fashion_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fashion_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fashion_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fashion_4.png"
]
}
],
"packs": [
{
"display_name": "Modern",
"pack_name": "modern",
"thumbnail": ["https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",
"https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",
"https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Neonpunk.png",],
"thumbnail_images": [
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.