Appearance
Markets
API Type
eCommerce API - Uses API key in request body. See Authentication.
Fetch available markets and get suggested markets based on user location.
Get Markets
Retrieve a list of available markets and optionally get a suggested market based on geographic coordinates.
Endpoint
POST https://{ecomm}.photobook.ai/api/v2/misc/get-market.phpReplace {ecomm} with your assigned client identifier.
Example: https://yourclient.photobook.ai/api/v2/misc/get-market.php
Authentication
See Authentication - eCommerce
Request Parameters
json
{
"env": "dev",
"key": "your-api-key",
"language": "en",
"latitude": 1.3521,
"longitude": 103.8198
}| Parameter | Type | Required | Description |
|---|---|---|---|
env | string | Yes | Target environment: dev or prod |
key | string | Yes | Your programmatic access key |
language | string | No | First 2 characters of language code (e.g., en for en-US). Defaults to en |
latitude | float | No | User's latitude. If provided with longitude, returns a suggested market |
longitude | float | No | User's longitude. If provided with latitude, returns a suggested market |
Response
json
{
"results": [
{
"marketId": 0,
"storeName": "Global Store",
"isoCode2": "US",
"currency": "USD",
"shipsWithin": [
{
"isoCode2": "US",
"name": "United States"
},
{
"isoCode2": "CA",
"name": "Canada"
}
]
}
],
"suggested": {
"marketId": 0,
"storeName": "Global Store",
"isoCode2": "US",
"currency": "USD",
"shipsWithin": [
{
"isoCode2": "US",
"name": "United States"
}
]
}
}Response Fields
results (array)
List of all available markets.
| Field | Type | Description |
|---|---|---|
marketId | integer | Unique market identifier |
storeName | string | Display name of the market |
isoCode2 | string | ISO 3166-1 alpha-2 country code |
currency | string | Currency code (e.g., USD, EUR) |
shipsWithin | array | List of countries/regions this market ships to |
shipsWithin (array)
| Field | Type | Description |
|---|---|---|
isoCode2 | string | ISO code of country or area (continent) |
name | string | Display name of country or area |
suggested (object)
Only returned if latitude and longitude were provided. Contains the same fields as objects in results.
Recommended Usage
Store the Selected Market
The marketId should be stored and used for subsequent API calls (products, projects, orders).
Auto-Select Based on Location
If you can retrieve the user's latitude and longitude:
- Call this API with location parameters
- Auto-select the
suggestedmarket - Still allow users to change their market via UI
This saves users the hassle of manually selecting a market.
Handle No Location Data
If latitude/longitude is not available:
Option 1: Prompt user to select market first
- Store the selection for future sessions
- Load products only after market is selected
Option 2: Load with default market
- Use
marketId: 0initially - Let users change market via dropdown in your UI
Refresh Products on Market Change
When a user changes their selected market, refetch the products as pricing and availability may differ.
Example Implementation
javascript
async function getMarkets(latitude, longitude) {
const response = await fetch('https://{ecomm}.photobook.ai/api/v2/misc/get-market.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
env: 'dev',
key: 'your-api-key',
language: 'en',
latitude: latitude,
longitude: longitude
})
});
const data = await response.json();
// Auto-select suggested market if available
const selectedMarket = data.suggested || data.results[0];
// Store marketId for future API calls
localStorage.setItem('marketId', selectedMarket.marketId);
return data;
}