API Reference - Location States Mapping

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000108126

← Back to API Reference | Getting Started

Location States Mapping

The Location States Mapping table stores the list of states and regions that a directory site has enabled for location-based browsing and SEO page generation. Unlike the global list_states reference table, this table contains only the states that are actively used on a specific site. Each record maps a state short code to its full name, URL slug, and country, enabling the platform to generate state-level browse pages and location filters. This is primarily a reference table used for GET operations; while CRUD endpoints are available, records are typically managed through the admin panel.

Model name in URL: location_states — DB table: location_states

The Location State Object

FieldTypeDescription
location_idintegerUnique location state ID (primary key, read-only)
state_snstringState/region short code (EG NY, CA); used for URL generation and cross-referencing location_cities; max 255 characters
state_lnstringFull state/region name (EG New York, California); max 255 characters
state_filenamestringURL-friendly slug for the state browse page (EG new-york, california); max 255 characters
country_snstringCountry short code (EG US, CA); references list_countries.country_code; max 255 characters

List Location States

GET /api/v2/location_states/get

Returns a paginated list of location state records.

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/location_states/get?limit=25" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "location_id": "1",
      "state_sn": "NY",
      "state_ln": "New York",
      "state_filename": "new-york",
      "country_sn": "US"
    },
    {
      "location_id": "2",
      "state_sn": "CA",
      "state_ln": "California",
      "state_filename": "california",
      "country_sn": "US"
    }
  ],
  "total": "65",
  "current_page": 1,
  "total_pages": 3,
  "next_page": "MipfKjI="
}

Retrieve a Location State Record

GET /api/v2/location_states/get/{location_id}

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/location_states/get/1" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "location_id": "1",
      "state_sn": "NY",
      "state_ln": "New York",
      "state_filename": "new-york",
      "country_sn": "US"
    }
  ],
  "total": "1",
  "current_page": 1,
  "total_pages": 1
}

Create a Location State Record

POST /api/v2/location_states/create

Example Request

Copy
curl -X POST "https://www.yourdomain.com/api/v2/location_states/create" \
  -H "X-Api-Key: your-api-key-here" \
  -d "state_sn=TX" \
  -d "state_ln=Texas" \
  -d "state_filename=texas" \
  -d "country_sn=US"

Example Response

Copy
{
  "status": "success",
  "message": {
    "location_id": "66",
    "state_sn": "TX",
    "state_ln": "Texas",
    "state_filename": "texas",
    "country_sn": "US"
  }
}

Update a Location State Record

PUT /api/v2/location_states/update

Example Request

Copy
curl -X PUT "https://www.yourdomain.com/api/v2/location_states/update" \
  -H "X-Api-Key: your-api-key-here" \
  -d "location_id=66" \
  -d "state_filename=texas-tx"

Example Response

Copy
{
  "status": "success",
  "message": {
    "location_id": "66",
    "state_sn": "TX",
    "state_ln": "Texas",
    "state_filename": "texas-tx",
    "country_sn": "US"
  }
}

Delete a Location State Record

DELETE /api/v2/location_states/delete

Example Request

Copy
curl -X DELETE "https://www.yourdomain.com/api/v2/location_states/delete" \
  -H "X-Api-Key: your-api-key-here" \
  -d "location_id=66"

Example Response

Copy
{
  "status": "success",
  "message": "location_states record was deleted"
}