nano-banana-experimental_2 / postman_collection.json
LogicGoInfotechSpaces's picture
Add category_id and user_id as optional parameters to all edit endpoints
4a1ba8d
{
"info": {
"_postman_id": "faae8a2c-bf0f-4c0f-9a4c-collection-nanobanana",
"name": "Nano Banana - Qwen Image Edit API",
"description": "Postman collection for the Nano Banana Qwen Image Edit API with Firebase App Check support.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Authentication",
"item": [
{
"name": "README - Authentication Overview",
"request": {
"method": "GET",
"description": "The Nano Banana API uses token-based authentication. There is no /login endpoint.\\n\\n- Include your Hugging Face token in the `Authorization: Bearer {{hfToken}}` header.\\n- Include your Firebase App Check token in the `X-Firebase-AppCheck: {{appCheckToken}}` header.\\n\\nSet both variables at the collection or environment level before sending any request.",
"header": [
{
"key": "Authorization",
"value": "Bearer {{hfToken}}",
"type": "text"
},
{
"key": "X-Firebase-AppCheck",
"value": "{{appCheckToken}}",
"type": "text"
}
],
"url": {
"raw": "{{baseUrl}}/health",
"host": [
"{{baseUrl}}"
],
"path": [
"health"
]
}
}
}
,
{
"name": "POST Set Tokens (Manual Login)",
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"const bodyRaw = pm.request.body && pm.request.body.raw ? pm.request.body.raw.trim() : \"\";",
"if (!bodyRaw) {",
" pm.environment.unset(\"hfToken\");",
" pm.environment.unset(\"appCheckToken\");",
" pm.console.log(\"No tokens provided in body. hfToken and appCheckToken were cleared.\");",
" return;",
"}",
"",
"let payload;",
"try {",
" payload = JSON.parse(bodyRaw);",
"} catch (err) {",
" throw new Error(\"Body must be valid JSON with hfToken/appCheckToken fields\");",
"}",
"",
"if (payload.hfToken) {",
" pm.environment.set(\"hfToken\", payload.hfToken);",
" pm.collectionVariables.set(\"hfToken\", payload.hfToken);",
"}",
"if (payload.appCheckToken) {",
" pm.environment.set(\"appCheckToken\", payload.appCheckToken);",
" pm.collectionVariables.set(\"appCheckToken\", payload.appCheckToken);",
"}",
"pm.variables.set(\"loginStatus\", \"Tokens updated\");"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"pm.test(\"Tokens stored\", function () {",
" pm.expect(pm.environment.get(\"hfToken\") || pm.collectionVariables.get(\"hfToken\")).to.be.ok;",
" pm.expect(pm.environment.get(\"appCheckToken\") || pm.collectionVariables.get(\"appCheckToken\")).to.be.ok;",
"});",
"pm.test(\"Login helper request completed\", function () {",
" pm.response.to.have.status(200);",
"});"
]
}
}
],
"request": {
"method": "POST",
"description": "Simulates a login step. Paste your Hugging Face token and Firebase App Check token in the JSON body and send this request. The tokens are stored in Postman variables for the other requests.",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"hfToken\": \"hf_xxx_your_token\",\n \"appCheckToken\": \"your_app_check_token\"\n}"
},
"url": {
"raw": "https://postman-echo.com/post",
"protocol": "https",
"host": [
"postman-echo",
"com"
],
"path": [
"post"
]
}
}
}
,
{
"name": "POST Firebase Auth Login",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"const jsonData = pm.response.json();",
"pm.test(\"Firebase login succeeded\", function () {",
" pm.expect(jsonData.idToken).to.exist;",
"});",
"",
"if (jsonData.idToken) {",
"pm.environment.set(\"firebaseIdToken\", jsonData.idToken);",
"pm.collectionVariables.set(\"firebaseIdToken\", jsonData.idToken);",
"pm.variables.set(\"loginStatus\", \"Firebase auth success\");",
"}",
"",
"if (jsonData.refreshToken) {",
"pm.environment.set(\"firebaseRefreshToken\", jsonData.refreshToken);",
"pm.collectionVariables.set(\"firebaseRefreshToken\", jsonData.refreshToken);",
"}"
]
}
}
],
"request": {
"method": "POST",
"description": "Use Firebase Authentication (email/password) to obtain an ID token. Set the variables `firebaseApiKey`, `firebaseEmail`, and `firebasePassword` before sending.",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"{{firebaseEmail}}\",\n \"password\": \"{{firebasePassword}}\",\n \"returnSecureToken\": true\n}"
},
"url": {
"raw": "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key={{firebaseApiKey}}",
"protocol": "https",
"host": [
"identitytoolkit",
"googleapis",
"com"
],
"path": [
"v1",
"accounts:signInWithPassword"
],
"query": [
{
"key": "key",
"value": "{{firebaseApiKey}}"
}
]
}
}
}
]
},
{
"name": "Health & Status",
"item": [
{
"name": "GET Root - Welcome",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{hfToken}}",
"type": "text",
"disabled": true
},
{
"key": "X-Firebase-AppCheck",
"value": "{{appCheckToken}}",
"type": "text",
"disabled": false
}
],
"url": {
"raw": "{{baseUrl}}/",
"host": [
"{{baseUrl}}"
],
"path": [
""
]
}
}
},
{
"name": "GET Health Check",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{hfToken}}",
"type": "text",
"disabled": true
},
{
"key": "X-Firebase-AppCheck",
"value": "{{appCheckToken}}",
"type": "text",
"disabled": false
}
],
"url": {
"raw": "{{baseUrl}}/health",
"host": [
"{{baseUrl}}"
],
"path": [
"health"
]
}
}
}
]
},
{
"name": "Image Editing",
"item": [
{
"name": "POST Edit Image - Nanobanana",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{hfToken}}",
"type": "text",
"disabled": false
},
{
"key": "X-Firebase-AppCheck",
"value": "{{appCheckToken}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "image",
"type": "file",
"src": "{{imagePath}}"
},
{
"key": "user_id",
"value": "{{userId}}",
"type": "text",
"disabled": false,
"description": "Optional: Integer user ID. Required for media_clicks logging."
},
{
"key": "category_id",
"value": "{{categoryId}}",
"type": "text",
"disabled": false,
"description": "Optional: MongoDB ObjectId string for category. Defaults to 69368d62b95a6c2a75920505 if not provided."
}
]
},
"url": {
"raw": "{{baseUrl}}/edit/nanobanana",
"host": [
"{{baseUrl}}"
],
"path": [
"edit",
"nanobanana"
]
},
"description": "Edit an image using the default nanobanana prompt. Automatically saves to nanobanana MongoDB database. No prompt parameter needed. If user_id is provided, automatically logs to media_clicks collection with categoryId: 69368d62b95a6c2a75920505"
},
"response": []
},
{
"name": "POST Edit Image - Descratch",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{hfToken}}",
"type": "text",
"disabled": false
},
{
"key": "X-Firebase-AppCheck",
"value": "{{appCheckToken}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "image",
"type": "file",
"src": "{{imagePath}}"
},
{
"key": "user_id",
"value": "{{userId}}",
"type": "text",
"disabled": false,
"description": "Optional: Integer user ID. Required for media_clicks logging."
},
{
"key": "category_id",
"value": "{{categoryId}}",
"type": "text",
"disabled": false,
"description": "Optional: MongoDB ObjectId string for category. Defaults to 69368fbb2e46bd68ae18899e if not provided."
}
]
},
"url": {
"raw": "{{baseUrl}}/edit/descratch",
"host": [
"{{baseUrl}}"
],
"path": [
"edit",
"descratch"
]
},
"description": "Edit an image using the default Descratch prompt. Automatically saves to Descratch_logicgo MongoDB database. No prompt parameter needed. If user_id is provided, automatically logs to media_clicks collection with categoryId: 69368fbb2e46bd68ae18899e"
},
"response": []
},
{
"name": "POST Edit Image - Custom Prompt",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{hfToken}}",
"type": "text",
"disabled": false
},
{
"key": "X-Firebase-AppCheck",
"value": "{{appCheckToken}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "prompt",
"value": "{{prompt}}",
"type": "text",
"disabled": false
},
{
"key": "db",
"value": "{{dbName}}",
"type": "text",
"disabled": false,
"description": "Optional: 'nanobanana' or 'Descratch_logicgo'"
},
{
"key": "user_id",
"value": "{{userId}}",
"type": "text",
"disabled": false,
"description": "Optional: Integer user ID. If provided with category_id, logs to media_clicks collection"
},
{
"key": "category_id",
"value": "{{categoryId}}",
"type": "text",
"disabled": false,
"description": "Optional: MongoDB ObjectId string for category (e.g., '69368fbb2e46bd68ae18899e')"
},
{
"key": "image",
"type": "file",
"src": "{{imagePath}}"
}
]
},
"url": {
"raw": "{{baseUrl}}/edit",
"host": [
"{{baseUrl}}"
],
"path": [
"edit"
]
},
"description": "Edit an image using a custom text prompt. Optionally saves to MongoDB if 'db' parameter is provided. If user_id and category_id are provided, logs to media_clicks collection."
},
"response": []
},
{
"name": "POST Test MongoDB Connection",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{hfToken}}",
"type": "text",
"disabled": false
},
{
"key": "X-Firebase-AppCheck",
"value": "{{appCheckToken}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "db",
"value": "{{dbName}}",
"type": "text"
}
]
},
"url": {
"raw": "{{baseUrl}}/test-mongodb",
"host": [
"{{baseUrl}}"
],
"path": [
"test-mongodb"
]
}
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"MongoDB test succeeded\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.status).to.eql(\"success\");",
"});"
],
"type": "text/javascript"
}
}
]
}
]
},
{
"name": "Logs",
"item": [
{
"name": "GET Get File Logs (Fallback)",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{hfToken}}",
"type": "text",
"disabled": false
},
{
"key": "X-Firebase-AppCheck",
"value": "{{appCheckToken}}",
"type": "text",
"disabled": false
}
],
"url": {
"raw": "{{baseUrl}}/logs/file/{{dbName}}",
"host": [
"{{baseUrl}}"
],
"path": [
"logs",
"file",
"{{dbName}}"
]
}
}
}
]
}
],
"variable": [
{
"key": "baseUrl",
"value": "https://logicgoinfotechspaces-nano-banana-experimental-2.hf.space"
},
{
"key": "hfToken",
"value": "",
"description": "Hugging Face token (leave empty if Space is public)."
},
{
"key": "appCheckToken",
"value": "YOUR_FIREBASE_APP_CHECK_TOKEN",
"description": "Use Firebase App Check client SDK to generate a token."
},
{
"key": "dbName",
"value": "nanobanana",
"description": "Either nanobanana or Descratch_logicgo."
},
{
"key": "prompt",
"value": "make the background blue",
"description": "Optional prompt. Leave empty when relying on default prompts."
},
{
"key": "imagePath",
"value": "/absolute/path/to/your/image.jpg",
"description": "Path to image file on your machine."
},
{
"key": "firebaseApiKey",
"value": "",
"description": "Firebase Web API key (from Firebase config)."
},
{
"key": "firebaseEmail",
"value": "",
"description": "Firebase Authentication email (if using password auth)."
},
{
"key": "firebasePassword",
"value": "",
"description": "Firebase Authentication password."
},
{
"key": "userId",
"value": "123",
"description": "Optional: Integer user ID for media_clicks logging. Must be a valid integer."
},
{
"key": "categoryId",
"value": "69368d62b95a6c2a75920505",
"description": "Optional: MongoDB ObjectId string for category (24 hex characters). Defaults: nanobanana=69368d62b95a6c2a75920505, descratch=69368fbb2e46bd68ae18899e"
}
]
}