Skip to content
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": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/modern_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/modern_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/modern_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/modern_4.png"
]
},
{
"display_name": "Magical & Fantasy",
"pack_name": "fantasy",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Fantasy.png",
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fantasy_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fantasy_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fantasy_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/fantasy_4.png"
]
},
{
"display_name": "Professional Headshots",
"pack_name": "headshots",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Headshots.png",
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/headshots_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/headshots_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/headshots_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/headshots_4.png"
]
},
{
"display_name": "Fictional Characters",
"pack_name": "characters",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Fictional%20characters.png",
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/characters_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/characters_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/characters_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/characters_4.png"
]
},
{
"display_name": "Science Fiction",
"pack_name": "science",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Science%20fiction.png",
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/science_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/science_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/science_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/science_4.png"
]
},
{
"display_name": "Seven Wonders of the World",
"pack_name": "seven_wonders",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Seven_Wonders.png",
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/seven_wonders_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/seven_wonders_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/seven_wonders_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/seven_wonders_4.png"
]
},
{
"display_name": "Neonpunk",
"pack_name": "neon",
"thumbnail": "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",
"pack_name": "gta",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Gta.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",
"pack_name": "historical",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Historical%20%26%20renaissance.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": "Doppelgängers",
"pack_name": "doppleganger",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Doppleganger.png",
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/doppleganger_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/doppleganger_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/doppleganger_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/doppleganger_4.png"
]
},
{
"display_name": "Fashion",
"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"
]
},
{
"display_name": "Olden Times",
"pack_name": "old",
"thumbnail": "https://storage.googleapis.com/jetrr-public/pack-thumbnails-v1/Olden%20times.png",
"thumbnail_images": [
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/old_1.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/old_2.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/old_3.png",
"https://storage.googleapis.com/jetrr-public/single-pack-images-v1/old_4.png"
]
}
]
}

Initialize Job

Endpoint: /initalize-job
Method: GET
Description: This endpoint is used to initialize a new job.
Example Request:
GET /initalize-job
Example Response:
{
"jobId": "1234"
}

Upload Image

Endpoint: /upload
Method: POST
Description: This endpoint is used to upload an image for a specific job.
Request Body:
jobId: The ID of the job.
image: The image file to be uploaded.
Example Request:
POST /upload
Content-Type: multipart/form-data;
Content-Disposition: form-data; name="image"; filename="example.jpg"
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.