The GraphQL endpoint covers the same geographic data as the REST API — countries, states, cities, regions, and subregions — through a single endpoint. Ask for exactly the fields you need, and resolve nested relationships (a country’s states, a state’s cities) in one request instead of chaining several REST calls yourself.
Available on the Professional and Business plans.Compare plans to add GraphQL to your API key.
When to use it
Reach for GraphQL when a screen needs a nested shape — for example a country with its states and each state’s cities — in one round trip. For a single flat list, the REST endpoints work just as well: they return the complete list in one response and are simpler to cache by URL.
Authentication
string
required
Your API key, the same header every REST endpoint uses.
Sending a query
Send a POST request with a JSON body containing a query string (and optional variables):
cURL
curl -X POST 'https://api.countrystatecity.in/v1/graphql' \ -H 'X-CSCAPI-KEY: YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{"query": "{ country(ciso: \"US\") { name capital currency } }"}'
A GET request to the same endpoint with an Accept header that includes text/html (what a browser sends) returns GraphiQL, an interactive schema explorer with autocomplete and inline docs for every type and field.The page is protected like any query: the request that loads it must carry your X-CSCAPI-KEY header, and your plan must include GraphQL. Typing the URL into the address bar sends no key, so it returns 401 instead of the explorer. To open it:
Install a browser extension that adds custom request headers, and set X-CSCAPI-KEY: YOUR_API_KEY for api.countrystatecity.in.
Open https://api.countrystatecity.in/v1/graphql.
In GraphiQL’s Headers panel, add {"X-CSCAPI-KEY": "YOUR_API_KEY"}. GraphiQL sends its queries with the headers from this panel.
Alternatively, use an API client with GraphQL support, such as Postman or Insomnia, with the header set. It can load the schema by introspection over an ordinary POST.Loading the page and each request GraphiQL sends count toward your daily and monthly usage like any other request. If your key restricts allowed domains or IPs, GraphiQL’s requests are checked against those restrictions too.
Nested queries
Fields that return related entities — Country.states, State.cities, Region.subregions, Subregion.countries — resolve in the same HTTP request, so one round trip replaces a chain of REST calls. Each nested list returns a page (20 rows per parent unless you pass limit), and every parent row adds a lookup to the query budget, so keep the outer lists small:
{ countries(searchQuery: "United", limit: 2) { name states(limit: 10) { name cities(limit: 10) { name } } }}
This returns the first 2 matching countries (sorted by name), up to 10 states for each, and up to 10 cities for each of those states: a page at every level, not every match. It is estimated at 23 lookups (1 for countries, 1 per country for states, 1 per state for cities) and 222 rows, well inside the budget.Nested lookups are not merged into a single database query. The server still fetches each parent’s children separately; it runs those lookups a limited number at a time in parallel and reuses a result when the same parent and page appear twice in one request. So the cities of 20 different states still cost 20 lookups.
Fields by plan
Two plan settings apply, separately:
The GraphQL feature decides whether you can call /v1/graphql at all. Professional and Business include it, and a custom plan can too. Supporter, for example, has full field access over REST but no GraphQL.
Your data access level decides which fields come back, using the same per-field filtering as REST. Professional and Business have full access, so every field in the schema is returned. A custom plan can have a lower level.
A field above your access level returns null rather than an error, so one query can safely ask for fields you might not have:
A custom plan can also be set to an intermediate level that returns the Full fields except translations (and, for countries, states and cities, wikiDataId).Only fields defined in the GraphQL schema can be requested. REST’s localized_name and matched_locale are not in it, and there are no locale or include_translations arguments: asking for localized_name is a validation error, not null. To show a name in another language, select translations (a JSON-encoded string keyed by language code) and pick the language in your app, or use the REST locale parameter.
Cities in a country, optionally narrowed to one state
city(id)
One city by numeric ID
regions(searchQuery, limit, offset)
All regions
region(id)
One region by numeric ID
subregions(region, searchQuery, limit, offset)
Subregions in one region (numeric region ID)
subregion(id)
One subregion by numeric ID
country(ciso) takes a numeric ID passed as a string, or an ISO2 code. An ISO3 code such as "USA" passes validation but matches nothing, so the query returns null; convert it first with Lookup Country by ISO Code. The country argument of states, state, and cities takes an ISO2 code, and state(iso) and cities(state) take the state’s code (for example CA).searchQuery (2 to 100 characters) keeps rows whose name (or, for countries, states, and cities, native name) contains it, ignoring case. A single-item query that matches nothing returns null with no error.
city(id) has no REST equivalent — it’s the one query only available through GraphQL, since REST only ever exposed cities scoped to a country or state.
Limits
Each HTTP request to /v1/graphql counts as one request against your plan’s daily and monthly limits, however many lookups it runs, including a request rejected for exceeding the query budget.
Pagination
Every list field, at the root or nested, takes limit and offset. They are arguments on the field inside your query, not URL query parameters.
offset defaults to 0. Lists are sorted by name, then ID, so stepping offset by limit pages through the full list. A limit above 1,000, or a negative limit or offset, is rejected rather than capped: it fails that field with a BAD_REQUEST error (see Errors). limit: 0 returns an empty list.Unlike the REST list endpoints, a GraphQL list never returns more than one page. Watch the nested default in particular: { country(ciso: "US") { states { name } } } returns only the first 20 states. Ask for more with states(limit: 100), or page with offset.
Query budget
Before running a query, the API estimates its cost from the limit of every list field (the value you pass, or the default above), not from how many rows actually match:
Lookups: every field that returns an object or a list of objects costs one lookup per parent row it runs under. Scalar fields such as name are free.
Rows: every list field adds its limit multiplied by the number of parent rows.
One query may use at most 50 lookups and 25,000 rows. A query over either limit is rejected with HTTP 400 before any data is fetched:
400 - Query too expensive
{ "errors": [ { "message": "Query is too expensive: its estimated cost exceeds the budget (1001 data lookups, 21000 rows; limits: 50 lookups, 25000 rows). Add or lower `limit:` arguments on list fields, remove a level of nesting, or split the request into several queries.", "extensions": { "code": "QUERY_TOO_EXPENSIVE", "statusCode": 400, "estimatedFetches": 1001, "estimatedRows": 21000, "maxFetches": 50, "maxRows": 25000 } } ]}
That response is for { countries { states { name } } }: countries defaults to 1,000 rows, so states would run 1,000 lookups. To stay within the budget, add or lower limit on the outer lists, drop a level of nesting, or split the work into several requests. For example, fetch a page of countries first, then request each country’s states and cities in a separate query, using offset for further pages.Queries are also limited to 5 levels of nesting. That is exactly the deepest chain the schema allows (regions → subregions → countries → states → cities), so in practice the budget is the limit you will reach.
Errors
The HTTP status and body depend on where a request fails:
Where it fails
HTTP status
Body
Before GraphQL runs: for example a missing or invalid key, a plan without GraphQL, or a usage limit reached
Query budget (QUERY_TOO_EXPENSIVE), or a document too large to analyze (QUERY_TOO_COMPLEX)
400
errors only, no data
Syntax error, or a field or argument that isn’t in the schema
200, or 400 if you send Accept: application/graphql-response+json
errors only, no data
Inside a field: invalid argument, a plan feature the field needs, temporary overload
200
errors plus whatever data could be resolved
Field errors carry extensions.code and extensions.statusCode: BAD_REQUEST (400) for an invalid argument such as a malformed country code or a limit over 1,000; FORBIDDEN (403) when your plan lacks a feature that field needs, with extensions.details naming the feature (standard Professional and Business plans include every feature these queries use); and API_ERROR for anything else. A 503 with GraphQL is busy. Please retry shortly. is temporary, so retry after a short wait.The failed field becomes null. When that field is nullable (the single-item queries such as country, and the nested lists such as Country.states), the rest of data still comes back. This response is for { country(ciso: "US") { name states(limit: 5000) { name } } }:
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Country State City Documentation","description":"Documentation for the Country State City ecosystem: a REST API, downloadable database and tools covering 250 countries, 5,000+ states and 150,000+ cities with ISO codes, coordinates, timezones and currencies.","colors":{"primary":"#2563EB","light":"#3B82F6","dark":"#1E40AF"},"logo":{"light":"https://mintcdn.com/webbywonder/DXb6lzT49e7Mz1Kh/logo/csc-docs-logo-dark.svg?fit=max\u0026auto=format\u0026n=DXb6lzT49e7Mz1Kh\u0026q=85\u0026s=893eeadd293f0443a7f2b192eb9b59d0","dark":"https://mintcdn.com/webbywonder/DXb6lzT49e7Mz1Kh/logo/csc-docs-logo-light.svg?fit=max\u0026auto=format\u0026n=DXb6lzT49e7Mz1Kh\u0026q=85\u0026s=cff7bfba805966e45c27a602c96e8252"},"favicon":"https://mintcdn.com/webbywonder/fAkIAEvO-IGHwy4I/favicon.svg?fit=max\u0026auto=format\u0026n=fAkIAEvO-IGHwy4I\u0026q=85\u0026s=1b0ea88bfb2dcdc3ed92888be25695ae","api":{"openapi":"https://raw.githubusercontent.com/dr5hn/csc-swagger-playground/main/config.json","playground":{"display":"interactive"},"mdx":{"auth":{"method":"key","name":"X-CSCAPI-KEY"},"server":"https://api.countrystatecity.in/v1"}},"navbar":{"links":[{"href":"https://countrystatecity.in","label":"Home"},{"href":"https://countrystatecity.in/pricing","label":"Pricing"},{"href":"https://countrystatecity.org","label":"Encyclopedia"}],"primary":{"type":"button","label":"Get API Key","href":"https://countrystatecity.in/product/api/"}},"footer":{"socials":{"github":"https://github.com/dr5hn/countries-states-cities-database","linkedin":"https://www.linkedin.com/in/dr5hn","x":"https://x.com/dr5hn"},"links":[{"header":"Products","items":[{"label":"REST API","href":"https://countrystatecity.in/product/api"},{"label":"Database","href":"https://countrystatecity.in/product/database"},{"label":"Export Tool","href":"https://export.countrystatecity.in/"},{"label":"Update Tool","href":"https://countrystatecity.in/product/update-tool"}]},{"header":"Resources","items":[{"label":"API Playground","href":"https://playground.countrystatecity.in/"},{"label":"Live Demo","href":"https://demo.countrystatecity.in/"},{"label":"Products","href":"https://countrystatecity.in/ecosystem"},{"label":"Changelog","href":"/changelog"},{"label":"Status","href":"https://status.countrystatecity.in/"}]},{"header":"Company","items":[{"label":"About","href":"https://countrystatecity.in/about"},{"label":"Pricing","href":"https://countrystatecity.in/pricing"},{"label":"Contact","href":"https://countrystatecity.in/contact"},{"label":"Encyclopedia","href":"https://countrystatecity.org/"}]}]},"search":{"prompt":"Search the documentation..."},"seo":{"metatags":{"og:site_name":"Country State City Docs","og:image":"https://docs.countrystatecity.in/images/hero-light.png","twitter:card":"summary_large_image","twitter:site":"@dr5hn","twitter:image":"https://docs.countrystatecity.in/images/hero-light.png","keywords":"country state city API, countries API, states API, cities API, ISO 3166, geographical database, location dropdown"}},"integrations":{"clarity":{"projectId":"z4ojfuzvou"},"ga4":{"measurementId":"G-7LDSKYGZJB"}},"banner":{"content":"[**MakeMySiteLive** Publish your website in under 2 minutes *New*](https://makemysitelive.com/?utm_source=csc-docs\u0026utm_medium=banner\u0026utm_campaign=cross-promo\u0026utm_content=makemysitelive) [**RemoteGigs** Find remote jobs and gigs](https://remotegig.in/?utm_source=csc-docs\u0026utm_medium=banner\u0026utm_campaign=cross-promo\u0026utm_content=remotegig)","dismissible":true},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"webbywonder","hasAudioNarration":false,"actualSubdomain":"webbywonder","customDomains":["docs.countrystatecity.in"],"gitSource":{"type":"github","owner":"dr5hn","repo":"csc-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"feedback":{"thumbs":true,"edits":true,"issues":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae314c9344aa043c1327bff","clientVersion":"0.0.4138","searchFilterCounts":[{"language":"default","tag":"API Reference","count":31},{"language":"default","tag":"Database","count":14},{"language":"default","tag":"API Guides","count":13},{"language":"default","tag":"Tools","count":12},{"language":"default","tag":"Installation Guides","count":7},{"language":"default","tag":"SDKs \u0026 Examples","count":6},{"language":"default","tag":"Database Documentation","count":6},{"language":"default","tag":"Update Tool","count":6},{"language":"default","tag":"Regions","count":5},{"language":"default","tag":"Export Tool","count":5}],"searchSettings":{"showContentSnippets":true,"isFiltersEnabled":true,"maxResults":10}},"assistantConfig":{"enableStarterQuestions":true,"enableContextualStarterQuestions":true,"deflection":{"enabled":true,"email":"[email protected]"}},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"privacy":{"consentBanner":{"enabled":true}},"googleFontsInlined":false},"customCss":[{"filePath":"custom.css","content":"#banner{background:#eef4fb;border-bottom:1px solid #dbe5f1;padding-top:6px;padding-bottom:6px}#banner>div{max-width:100%}#banner p{display:flex;flex-wrap:nowrap;align-items:center;justify-content:center;gap:8px 12px;margin:0}#banner a{display:inline-flex;align-items:center;gap:8px;padding:4px 12px 4px 4px;background:#ffffff;border:1px solid #dbe5f1;border-radius:999px;flex:none;font-family:Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;font-size:13px;font-weight:400;text-decoration:none;white-space:nowrap;transition:box-shadow 0.15s ease, border-color 0.15s ease}#banner a:hover{border-color:#bcd0ea;box-shadow:0 1px 6px rgba(37, 99, 235, 0.15)}#banner a,#banner a *{-webkit-text-fill-color:#475569}#banner a [data-streamdown=\"strong\"]{white-space:nowrap;font-weight:600;-webkit-text-fill-color:#0f172a}#banner a::before{content:'';flex:none;width:24px;height:24px;background:no-repeat center / cover;border-radius:7px}#banner a:nth-of-type(1)::before{background-image:url('/images/makemysitelive-icon.png')}#banner a:nth-of-type(2)::before{background-image:url('/images/remotegigs-icon.png');border-radius:50%}#banner a::after{content:'';flex:none;width:12px;height:12px;background-color:#2563eb;-webkit-mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E\") no-repeat center / contain;mask:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E\") no-repeat center / contain}#banner a em{padding:1px 8px;background:#fef3c7;border-radius:999px;font-size:11px;font-style:normal;font-weight:500;-webkit-text-fill-color:#92400e}#banner button{right:6px;opacity:0.6}#banner button:hover{opacity:1;background:rgba(15, 23, 42, 0.08)}#banner button svg path{stroke:#334155}@media (min-width: 901px) and (max-width: 1024px){#banner p{gap:8px;padding:0 40px}#banner a{gap:6px;padding:4px 10px 4px 4px;font-size:12.5px}}@media (min-width: 768px) and (max-width: 900px){#banner p{gap:6px;padding:0 32px}#banner a{gap:6px;padding:3px 10px 3px 3px;font-size:12px}#banner a::before{width:20px;height:20px}#banner a::after{width:10px;height:10px}#banner a em{display:none}}@media (max-width: 767px){#banner p{gap:6px;padding:0 28px}#banner a{font-size:0;gap:5px;padding:3px 8px 3px 3px}#banner a *:not([data-streamdown=\"strong\"]){font-size:0}#banner a [data-streamdown=\"strong\"]{font-size:12px}#banner a::before{width:20px;height:20px}#banner a::after{width:10px;height:10px}#banner a em{display:none}}@media (max-width: 400px){#banner a{gap:3px;padding-right:6px}#banner a [data-streamdown=\"strong\"]{font-size:11px}#banner a::after{display:none}}.dark #banner{background:#0f1b33;border-bottom-color:#1e2d4a}.dark #banner a{background:#16233f;border-color:#28395c}.dark #banner a,.dark #banner a *{-webkit-text-fill-color:#cbd5e1}.dark #banner a [data-streamdown=\"strong\"]{-webkit-text-fill-color:#f1f5f9}.dark #banner a::after{background-color:#60a5fa}.dark #banner a em{background:#3b2f0b;-webkit-text-fill-color:#fcd34d}.dark #banner button:hover{background:rgba(255, 255, 255, 0.1)}.dark #banner button svg path{stroke:#cbd5e1}"}],"page":{"pagePath":"api/graphql","slug":"/api/graphql","pageMetadata":{"title":"GraphQL API","api":"POST https://api.countrystatecity.in/v1/graphql","authMethod":"key","description":"Query countries, states, cities, regions, and subregions with GraphQL instead of REST","href":"/api/graphql"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Query countries, states, cities, regions, and subregions with GraphQL instead of REST\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{Card,CardGroup,CodeBlock,Heading,Info,Note,ParamField,Table}=_components;if(!Card)_missingMdxReference(`Card`,true);if(!CardGroup)_missingMdxReference(`CardGroup`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!Note)_missingMdxReference(`Note`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`The GraphQL endpoint covers the same geographic data as the REST API — countries, states, cities, regions, and subregions — through a single endpoint. Ask for exactly the fields you need, and resolve nested relationships (a country’s states, a state’s cities) in one request instead of chaining several REST calls yourself.`}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`Available on the Professional and Business plans.`}),` `,_jsx(_components.a,{href:`https://countrystatecity.in/pricing?source=docs\u0026campaign=graphql`,children:`Compare plans`}),` to add GraphQL to your API key.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`when-to-use-it`,children:`When to use it`}),`\n`,_jsx(_components.p,{children:`Reach for GraphQL when a screen needs a nested shape — for example a country with its states and each state’s cities — in one round trip. For a single flat list, the REST endpoints work just as well: they return the complete list in one response and are simpler to cache by URL.`}),`\n`,_jsx(Heading,{level:`2`,id:`authentication`,children:`Authentication`}),`\n`,_jsx(ParamField,{header:`X-CSCAPI-KEY`,type:`string`,required:true,id:`param-x-cscapi-key`,children:_jsx(_components.p,{children:`Your API key, the same header every REST endpoint uses.`})}),`\n`,_jsx(Heading,{level:`2`,id:`sending-a-query`,children:`Sending a query`}),`\n`,_jsxs(_components.p,{children:[`Send a `,_jsx(_components.code,{children:`POST`}),` request with a JSON body containing a `,_jsx(_components.code,{children:`query`}),` string (and optional `,_jsx(_components.code,{children:`variables`}),`):`]}),`\n`,_jsx(CodeBlock,{filename:`cURL`,numberOfLines:`4`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'https://api.countrystatecity.in/v1/graphql'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'X-CSCAPI-KEY: YOUR_API_KEY'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Content-Type: application/json'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{\"query\": \"{ country(ciso: \\\\\"US\\\\\") { name capital currency } }\"}'`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:`JavaScript`,numberOfLines:`11`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'https://api.countrystatecity.in/v1/graphql'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'POST'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'X-CSCAPI-KEY'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'YOUR_API_KEY'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'Content-Type'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'application/json'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` body:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` JSON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`stringify`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` query:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{ country(ciso: \"US\") { name capital currency } }'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:`Python`,numberOfLines:`9`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` requests.post(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'https://api.countrystatecity.in/v1/graphql'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` json`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'query'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'{ country(ciso: \"US\") { name capital currency } }'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` headers`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'X-CSCAPI-KEY'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'YOUR_API_KEY'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response.raise_for_status()`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`data `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response.json()[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'data'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:`200 - Response`,numberOfLines:`9`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`9`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"country\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"United States\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"capital\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Washington\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"currency\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"USD\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`exploring-the-schema`,children:`Exploring the schema`}),`\n`,_jsxs(_components.p,{children:[`A `,_jsx(_components.code,{children:`GET`}),` request to the same endpoint with an `,_jsx(_components.code,{children:`Accept`}),` header that includes `,_jsx(_components.code,{children:`text/html`}),` (what a browser sends) returns GraphiQL, an interactive schema explorer with autocomplete and inline docs for every type and field.`]}),`\n`,_jsxs(_components.p,{children:[`The page is protected like any query: the request that loads it must carry your `,_jsx(_components.code,{children:`X-CSCAPI-KEY`}),` header, and your plan must include GraphQL. Typing the URL into the address bar sends no key, so it returns `,_jsx(_components.code,{children:`401`}),` instead of the explorer. To open it:`]}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Install a browser extension that adds custom request headers, and set `,_jsx(_components.code,{children:`X-CSCAPI-KEY: YOUR_API_KEY`}),` for `,_jsx(_components.code,{children:`api.countrystatecity.in`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Open `,_jsx(_components.code,{children:`https://api.countrystatecity.in/v1/graphql`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`In GraphiQL’s `,_jsx(_components.strong,{children:`Headers`}),` panel, add `,_jsx(_components.code,{children:`{\"X-CSCAPI-KEY\": \"YOUR_API_KEY\"}`}),`. GraphiQL sends its queries with the headers from this panel.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Alternatively, use an API client with GraphQL support, such as Postman or Insomnia, with the header set. It can load the schema by introspection over an ordinary `,_jsx(_components.code,{children:`POST`}),`.`]}),`\n`,_jsx(_components.p,{children:`Loading the page and each request GraphiQL sends count toward your daily and monthly usage like any other request. If your key restricts allowed domains or IPs, GraphiQL’s requests are checked against those restrictions too.`}),`\n`,_jsx(Heading,{level:`2`,id:`nested-queries`,children:`Nested queries`}),`\n`,_jsxs(_components.p,{children:[`Fields that return related entities — `,_jsx(_components.code,{children:`Country.states`}),`, `,_jsx(_components.code,{children:`State.cities`}),`, `,_jsx(_components.code,{children:`Region.subregions`}),`, `,_jsx(_components.code,{children:`Subregion.countries`}),` — resolve in the same HTTP request, so one round trip replaces a chain of REST calls. Each nested list returns a page (20 rows per parent unless you pass `,_jsx(_components.code,{children:`limit`}),`), and every parent row adds a lookup to the `,_jsx(_components.a,{href:`#query-budget`,children:`query budget`}),`, so keep the outer lists small:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`graphql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`graphql`,children:_jsxs(_components.code,{language:`graphql`,numberOfLines:`11`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` countries`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`searchQuery`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"United\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`limit`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` states`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`limit`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`10`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` cities`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`limit`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`10`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` name`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`This returns the first 2 matching countries (sorted by name), up to 10 states for each, and up to 10 cities for each of those states: a page at every level, not every match. It is estimated at 23 lookups (1 for `,_jsx(_components.code,{children:`countries`}),`, 1 per country for `,_jsx(_components.code,{children:`states`}),`, 1 per state for `,_jsx(_components.code,{children:`cities`}),`) and 222 rows, well inside the budget.`]}),`\n`,_jsx(_components.p,{children:`Nested lookups are not merged into a single database query. The server still fetches each parent’s children separately; it runs those lookups a limited number at a time in parallel and reuses a result when the same parent and page appear twice in one request. So the cities of 20 different states still cost 20 lookups.`}),`\n`,_jsx(Heading,{level:`2`,id:`fields-by-plan`,children:`Fields by plan`}),`\n`,_jsx(_components.p,{children:`Two plan settings apply, separately:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`The GraphQL feature`}),` decides whether you can call `,_jsx(_components.code,{children:`/v1/graphql`}),` at all. Professional and Business include it, and a custom plan can too. Supporter, for example, has full field access over REST but no GraphQL.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Your data access level`}),` decides which fields come back, using the same per-field filtering as REST. Professional and Business have `,_jsx(_components.strong,{children:`full`}),` access, so every field in the schema is returned. A custom plan can have a lower level.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`A field above your access level returns `,_jsx(_components.code,{children:`null`}),` rather than an error, so one query can safely ask for fields you might not have:`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Type`}),_jsx(_components.th,{children:`Basic`}),_jsx(_components.th,{children:`Full adds`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`Country`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`id`}),`, `,_jsx(_components.code,{children:`name`}),`, `,_jsx(_components.code,{children:`iso2`}),`, `,_jsx(_components.code,{children:`iso3`}),`, `,_jsx(_components.code,{children:`phonecode`}),`, `,_jsx(_components.code,{children:`capital`}),`, `,_jsx(_components.code,{children:`currency`}),`, `,_jsx(_components.code,{children:`native`}),`, `,_jsx(_components.code,{children:`emoji`}),`, `,_jsx(_components.code,{children:`latitude`}),`, `,_jsx(_components.code,{children:`longitude`}),`, `,_jsx(_components.code,{children:`region`}),`, `,_jsx(_components.code,{children:`region_id`}),`, `,_jsx(_components.code,{children:`subregion`}),`, `,_jsx(_components.code,{children:`subregion_id`}),`, `,_jsx(_components.code,{children:`timezones`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`numeric_code`}),`, `,_jsx(_components.code,{children:`currency_name`}),`, `,_jsx(_components.code,{children:`currency_symbol`}),`, `,_jsx(_components.code,{children:`tld`}),`, `,_jsx(_components.code,{children:`nationality`}),`, `,_jsx(_components.code,{children:`population`}),`, `,_jsx(_components.code,{children:`gdp`}),`, `,_jsx(_components.code,{children:`area_sq_km`}),`, `,_jsx(_components.code,{children:`postal_code_format`}),`, `,_jsx(_components.code,{children:`postal_code_regex`}),`, `,_jsx(_components.code,{children:`emojiU`}),`, `,_jsx(_components.code,{children:`translations`}),`, `,_jsx(_components.code,{children:`wikiDataId`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`State`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`id`}),`, `,_jsx(_components.code,{children:`name`}),`, `,_jsx(_components.code,{children:`iso2`}),`, `,_jsx(_components.code,{children:`country_id`}),`, `,_jsx(_components.code,{children:`country_code`}),`, `,_jsx(_components.code,{children:`latitude`}),`, `,_jsx(_components.code,{children:`longitude`}),`, `,_jsx(_components.code,{children:`timezone`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`fips_code`}),`, `,_jsx(_components.code,{children:`iso3166_2`}),`, `,_jsx(_components.code,{children:`type`}),`, `,_jsx(_components.code,{children:`level`}),`, `,_jsx(_components.code,{children:`parent_id`}),`, `,_jsx(_components.code,{children:`native`}),`, `,_jsx(_components.code,{children:`population`}),`, `,_jsx(_components.code,{children:`translations`}),`, `,_jsx(_components.code,{children:`wikiDataId`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`City`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`id`}),`, `,_jsx(_components.code,{children:`name`}),`, `,_jsx(_components.code,{children:`kind`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`state_id`}),`, `,_jsx(_components.code,{children:`state_code`}),`, `,_jsx(_components.code,{children:`country_id`}),`, `,_jsx(_components.code,{children:`country_code`}),`, `,_jsx(_components.code,{children:`latitude`}),`, `,_jsx(_components.code,{children:`longitude`}),`, `,_jsx(_components.code,{children:`timezone`}),`, `,_jsx(_components.code,{children:`population`}),`, `,_jsx(_components.code,{children:`type`}),`, `,_jsx(_components.code,{children:`level`}),`, `,_jsx(_components.code,{children:`parent_id`}),`, `,_jsx(_components.code,{children:`native`}),`, `,_jsx(_components.code,{children:`translations`}),`, `,_jsx(_components.code,{children:`wikiDataId`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`Region`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`id`}),`, `,_jsx(_components.code,{children:`name`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`wikiDataId`}),`, `,_jsx(_components.code,{children:`translations`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`Subregion`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`id`}),`, `,_jsx(_components.code,{children:`name`}),`, `,_jsx(_components.code,{children:`region_id`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`wikiDataId`}),`, `,_jsx(_components.code,{children:`translations`})]})]})]})]}),`\n`,_jsxs(_components.p,{children:[`A custom plan can also be set to an intermediate level that returns the Full fields except `,_jsx(_components.code,{children:`translations`}),` (and, for countries, states and cities, `,_jsx(_components.code,{children:`wikiDataId`}),`).`]}),`\n`,_jsxs(_components.p,{children:[`Only fields defined in the GraphQL schema can be requested. REST’s `,_jsx(_components.code,{children:`localized_name`}),` and `,_jsx(_components.code,{children:`matched_locale`}),` are not in it, and there are no `,_jsx(_components.code,{children:`locale`}),` or `,_jsx(_components.code,{children:`include_translations`}),` arguments: asking for `,_jsx(_components.code,{children:`localized_name`}),` is a validation error, not `,_jsx(_components.code,{children:`null`}),`. To show a name in another language, select `,_jsx(_components.code,{children:`translations`}),` (a JSON-encoded string keyed by language code) and pick the language in your app, or use the REST `,_jsxs(_components.a,{href:`/api/localization`,children:[_jsx(_components.code,{children:`locale`}),` parameter`]}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`available-queries`,children:`Available queries`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Query`}),_jsx(_components.th,{children:`Returns`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`countries(searchQuery, limit, offset)`})}),_jsx(_components.td,{children:`All countries`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`country(ciso)`})}),_jsx(_components.td,{children:`One country by numeric ID or ISO2 code`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`states(country, searchQuery, limit, offset)`})}),_jsx(_components.td,{children:`States in one country`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`allStates(searchQuery, limit, offset)`})}),_jsx(_components.td,{children:`All states globally`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`state(country, iso)`})}),_jsx(_components.td,{children:`One state by country and state code`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`cities(country, state, searchQuery, limit, offset)`})}),_jsx(_components.td,{children:`Cities in a country, optionally narrowed to one state`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`city(id)`})}),_jsx(_components.td,{children:`One city by numeric ID`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`regions(searchQuery, limit, offset)`})}),_jsx(_components.td,{children:`All regions`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`region(id)`})}),_jsx(_components.td,{children:`One region by numeric ID`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`subregions(region, searchQuery, limit, offset)`})}),_jsx(_components.td,{children:`Subregions in one region (numeric region ID)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`subregion(id)`})}),_jsx(_components.td,{children:`One subregion by numeric ID`})]})]})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`country(ciso)`}),` takes a numeric ID passed as a string, or an ISO2 code. An ISO3 code such as `,_jsx(_components.code,{children:`\"USA\"`}),` passes validation but matches nothing, so the query returns `,_jsx(_components.code,{children:`null`}),`; convert it first with `,_jsx(_components.a,{href:`/api/endpoints/lookup-country-by-iso`,children:`Lookup Country by ISO Code`}),`. The `,_jsx(_components.code,{children:`country`}),` argument of `,_jsx(_components.code,{children:`states`}),`, `,_jsx(_components.code,{children:`state`}),`, and `,_jsx(_components.code,{children:`cities`}),` takes an ISO2 code, and `,_jsx(_components.code,{children:`state(iso)`}),` and `,_jsx(_components.code,{children:`cities(state)`}),` take the state’s code (for example `,_jsx(_components.code,{children:`CA`}),`).`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`searchQuery`}),` (2 to 100 characters) keeps rows whose name (or, for countries, states, and cities, native name) contains it, ignoring case. A single-item query that matches nothing returns `,_jsx(_components.code,{children:`null`}),` with no error.`]}),`\n`,_jsx(Info,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`city(id)`}),` has no REST equivalent — it’s the one query only available through GraphQL, since REST only ever exposed cities scoped to a country or state.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`limits`,children:`Limits`}),`\n`,_jsxs(_components.p,{children:[`Each HTTP request to `,_jsx(_components.code,{children:`/v1/graphql`}),` counts as one request against your plan’s daily and monthly limits, however many lookups it runs, including a request rejected for exceeding the query budget.`]}),`\n`,_jsx(Heading,{level:`3`,id:`pagination`,children:`Pagination`}),`\n`,_jsxs(_components.p,{children:[`Every list field, at the root or nested, takes `,_jsx(_components.code,{children:`limit`}),` and `,_jsx(_components.code,{children:`offset`}),`. They are arguments on the field inside your query, not URL query parameters.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`List field`}),_jsxs(_components.th,{children:[`Default `,_jsx(_components.code,{children:`limit`})]}),_jsxs(_components.th,{children:[`Maximum `,_jsx(_components.code,{children:`limit`})]})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[`Root queries: `,_jsx(_components.code,{children:`countries`}),`, `,_jsx(_components.code,{children:`states`}),`, `,_jsx(_components.code,{children:`allStates`}),`, `,_jsx(_components.code,{children:`cities`}),`, `,_jsx(_components.code,{children:`regions`}),`, `,_jsx(_components.code,{children:`subregions`})]}),_jsx(_components.td,{\"data-numeric\":`true`,children:`1,000`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`1,000`})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[`Nested fields: `,_jsx(_components.code,{children:`Country.states`}),`, `,_jsx(_components.code,{children:`State.cities`}),`, `,_jsx(_components.code,{children:`Region.subregions`}),`, `,_jsx(_components.code,{children:`Subregion.countries`})]}),_jsx(_components.td,{children:`20 per parent`}),_jsx(_components.td,{\"data-numeric\":`true`,children:`1,000`})]})]})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`offset`}),` defaults to `,_jsx(_components.code,{children:`0`}),`. Lists are sorted by name, then ID, so stepping `,_jsx(_components.code,{children:`offset`}),` by `,_jsx(_components.code,{children:`limit`}),` pages through the full list. A `,_jsx(_components.code,{children:`limit`}),` above 1,000, or a negative `,_jsx(_components.code,{children:`limit`}),` or `,_jsx(_components.code,{children:`offset`}),`, is rejected rather than capped: it fails that field with a `,_jsx(_components.code,{children:`BAD_REQUEST`}),` error (see `,_jsx(_components.a,{href:`#errors`,children:`Errors`}),`). `,_jsx(_components.code,{children:`limit: 0`}),` returns an empty list.`]}),`\n`,_jsxs(_components.p,{children:[`Unlike the REST list endpoints, a GraphQL list never returns more than one page. Watch the nested default in particular: `,_jsx(_components.code,{children:`{ country(ciso: \"US\") { states { name } } }`}),` returns only the first 20 states. Ask for more with `,_jsx(_components.code,{children:`states(limit: 100)`}),`, or page with `,_jsx(_components.code,{children:`offset`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`query-budget`,children:`Query budget`}),`\n`,_jsxs(_components.p,{children:[`Before running a query, the API estimates its cost from the `,_jsx(_components.code,{children:`limit`}),` of every list field (the value you pass, or the default above), not from how many rows actually match:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Lookups:`}),` every field that returns an object or a list of objects costs one lookup per parent row it runs under. Scalar fields such as `,_jsx(_components.code,{children:`name`}),` are free.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Rows:`}),` every list field adds its `,_jsx(_components.code,{children:`limit`}),` multiplied by the number of parent rows.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`One query may use at most `,_jsx(_components.strong,{children:`50 lookups`}),` and `,_jsx(_components.strong,{children:`25,000 rows`}),`. A query over either limit is rejected with HTTP `,_jsx(_components.code,{children:`400`}),` before any data is fetched:`]}),`\n`,_jsx(CodeBlock,{filename:`400 - Query too expensive`,numberOfLines:`15`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`15`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"errors\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"message\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:'\"Query is too expensive: its estimated cost exceeds the budget (1001 data lookups, 21000 rows; limits: 50 lookups, 25000 rows). Add or lower `limit:` arguments on list fields, remove a level of nesting, or split the request into several queries.\"'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"extensions\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"QUERY_TOO_EXPENSIVE\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"statusCode\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`400`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"estimatedFetches\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1001`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"estimatedRows\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`21000`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"maxFetches\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`50`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"maxRows\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`25000`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`That response is for `,_jsx(_components.code,{children:`{ countries { states { name } } }`}),`: `,_jsx(_components.code,{children:`countries`}),` defaults to 1,000 rows, so `,_jsx(_components.code,{children:`states`}),` would run 1,000 lookups. To stay within the budget, add or lower `,_jsx(_components.code,{children:`limit`}),` on the outer lists, drop a level of nesting, or split the work into several requests. For example, fetch a page of countries first, then request each country’s states and cities in a separate query, using `,_jsx(_components.code,{children:`offset`}),` for further pages.`]}),`\n`,_jsxs(_components.p,{children:[`Queries are also limited to 5 levels of nesting. That is exactly the deepest chain the schema allows (`,_jsx(_components.code,{children:`regions`}),` → `,_jsx(_components.code,{children:`subregions`}),` → `,_jsx(_components.code,{children:`countries`}),` → `,_jsx(_components.code,{children:`states`}),` → `,_jsx(_components.code,{children:`cities`}),`), so in practice the budget is the limit you will reach.`]}),`\n`,_jsx(Heading,{level:`2`,id:`errors`,children:`Errors`}),`\n`,_jsx(_components.p,{children:`The HTTP status and body depend on where a request fails:`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Where it fails`}),_jsx(_components.th,{children:`HTTP status`}),_jsx(_components.th,{children:`Body`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Before GraphQL runs: for example a missing or invalid key, a plan without GraphQL, or a usage limit reached`}),_jsxs(_components.td,{\"data-numeric\":`true`,children:[_jsx(_components.code,{children:`401`}),`, `,_jsx(_components.code,{children:`403`}),`, `,_jsx(_components.code,{children:`429`})]}),_jsxs(_components.td,{children:[`The REST error envelope (`,_jsx(_components.code,{children:`status`}),`, `,_jsx(_components.code,{children:`message`}),`, `,_jsx(_components.code,{children:`details`}),`); see `,_jsx(_components.a,{href:`/api/errors`,children:`Errors \u0026 Rate Limits`})]})]}),_jsxs(_components.tr,{children:[_jsxs(_components.td,{children:[`Query budget (`,_jsx(_components.code,{children:`QUERY_TOO_EXPENSIVE`}),`), or a document too large to analyze (`,_jsx(_components.code,{children:`QUERY_TOO_COMPLEX`}),`)`]}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`400`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`errors`}),` only, no `,_jsx(_components.code,{children:`data`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Syntax error, or a field or argument that isn’t in the schema`}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`200`}),`, or `,_jsx(_components.code,{children:`400`}),` if you send `,_jsx(_components.code,{children:`Accept: application/graphql-response+json`})]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`errors`}),` only, no `,_jsx(_components.code,{children:`data`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Inside a field: invalid argument, a plan feature the field needs, temporary overload`}),_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`200`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`errors`}),` plus whatever `,_jsx(_components.code,{children:`data`}),` could be resolved`]})]})]})]}),`\n`,_jsxs(_components.p,{children:[`Field errors carry `,_jsx(_components.code,{children:`extensions.code`}),` and `,_jsx(_components.code,{children:`extensions.statusCode`}),`: `,_jsx(_components.code,{children:`BAD_REQUEST`}),` (`,_jsx(_components.code,{children:`400`}),`) for an invalid argument such as a malformed country code or a `,_jsx(_components.code,{children:`limit`}),` over 1,000; `,_jsx(_components.code,{children:`FORBIDDEN`}),` (`,_jsx(_components.code,{children:`403`}),`) when your plan lacks a feature that field needs, with `,_jsx(_components.code,{children:`extensions.details`}),` naming the feature (standard Professional and Business plans include every feature these queries use); and `,_jsx(_components.code,{children:`API_ERROR`}),` for anything else. A `,_jsx(_components.code,{children:`503`}),` with `,_jsx(_components.code,{children:`GraphQL is busy. Please retry shortly.`}),` is temporary, so retry after a short wait.`]}),`\n`,_jsxs(_components.p,{children:[`The failed field becomes `,_jsx(_components.code,{children:`null`}),`. When that field is nullable (the single-item queries such as `,_jsx(_components.code,{children:`country`}),`, and the nested lists such as `,_jsx(_components.code,{children:`Country.states`}),`), the rest of `,_jsx(_components.code,{children:`data`}),` still comes back. This response is for `,_jsx(_components.code,{children:`{ country(ciso: \"US\") { name states(limit: 5000) { name } } }`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:`200 - Partial data`,numberOfLines:`17`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`17`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"errors\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"message\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"limit must not exceed 1000.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"extensions\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"BAD_REQUEST\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"statusCode\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`400`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"data\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"country\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"United States\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"states\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`null`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Root list queries (`,_jsx(_components.code,{children:`countries`}),`, `,_jsx(_components.code,{children:`states`}),`, `,_jsx(_components.code,{children:`cities`}),`, and the others) can’t be `,_jsx(_components.code,{children:`null`}),`, so an error in one of them makes all of `,_jsx(_components.code,{children:`data`}),` `,_jsx(_components.code,{children:`null`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`start-querying`,children:`Start querying`}),`\n`,_jsxs(CardGroup,{cols:2,children:[_jsx(Card,{title:`Compare API plans`,icon:`credit-card`,href:`https://countrystatecity.in/pricing?source=docs\u0026campaign=graphql`,children:_jsx(_components.p,{children:`Choose Professional or Business to add GraphQL to your API key.`})}),_jsx(Card,{title:`Errors \u0026 Rate Limits`,icon:`triangle-exclamation`,href:`/api/errors`,children:_jsxs(_components.p,{children:[`Handle the `,_jsx(_components.code,{children:`401`}),`, `,_jsx(_components.code,{children:`403`}),`, and `,_jsx(_components.code,{children:`429`}),` responses returned before a query runs.`]})})]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"GraphQL API","api":"POST https://api.countrystatecity.in/v1/graphql","authMethod":"key","description":"Query countries, states, cities, regions, and subregions with GraphQL instead of REST","href":"/api/graphql"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"When to use it","slug":"when-to-use-it","depth":2,"children":[]},{"title":"Authentication","slug":"authentication","depth":2,"children":[]},{"title":"Sending a query","slug":"sending-a-query","depth":2,"children":[]},{"title":"Exploring the schema","slug":"exploring-the-schema","depth":2,"children":[]},{"title":"Nested queries","slug":"nested-queries","depth":2,"children":[]},{"title":"Fields by plan","slug":"fields-by-plan","depth":2,"children":[]},{"title":"Available queries","slug":"available-queries","depth":2,"children":[]},{"title":"Limits","slug":"limits","depth":2,"children":[{"title":"Pagination","slug":"pagination","depth":3,"children":[]},{"title":"Query budget","slug":"query-budget","depth":3,"children":[]}]},{"title":"Errors","slug":"errors","depth":2,"children":[]},{"title":"Start querying","slug":"start-querying","depth":2,"children":[]}],"codeExamples":{},"endpoint":{"title":"GraphQL API","path":"/v1/graphql","servers":[{"url":"https://api.countrystatecity.in"}],"method":"post","request":{"security":[{"title":"API Key Auth","parameters":{"header":{"X-CSCAPI-KEY":{"type":"apiKey"}},"query":{},"cookie":{}}}],"parameters":{"query":{},"header":{"X-CSCAPI-KEY":{"schema":[{"type":"string","description":"Your API key, the same header every REST endpoint uses.","required":true}]}},"cookie":{},"path":{}},"body":{}},"response":{},"deprecated":false}},"jsLinks":["/_mintlify/custom/webbywonder/953dd63308a65b36/scripts/sync-changelog.js","/_mintlify/custom/webbywonder/f786c45307885d47/scripts/update-database-stats.js"],"subdomain":"webbywonder","siteName":"Country State City Documentation","title":"GraphQL API - Country State City Documentation","relatedPagesConfig":{"enabled":true,"limit":5,"mode":"automatic"},"contextualStarterQuestions":[{"_id":"6acaa0d6fbd69a7ea3c9585b","deploymentId":"68c5124ba1ff923c83a9da5f","questionText":"How do I authenticate?","status":"active","generatedBy":"contextual","path":"api/graphql","createdAt":"2026-10-10T20:32:22.922Z","updatedAt":"2026-10-10T20:32:22.922Z","__v":0},{"_id":"6acaa0d6fbd69a7ea3c9585a","deploymentId":"68c5124ba1ff923c83a9da5f","questionText":"When should I use GraphQL?","status":"active","generatedBy":"contextual","path":"api/graphql","createdAt":"2026-10-10T20:32:22.922Z","updatedAt":"2026-10-10T20:32:22.922Z","__v":0},{"_id":"6acaa0d6fbd69a7ea3c95859","deploymentId":"68c5124ba1ff923c83a9da5f","questionText":"How do I query countries?","status":"active","generatedBy":"contextual","path":"api/graphql","createdAt":"2026-10-10T20:32:22.922Z","updatedAt":"2026-10-10T20:32:22.922Z","__v":0}],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-29T14:12:46.502Z","originalFileLocation":"api/graphql.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Query countries, states, cities, regions, and subregions with GraphQL instead of REST\">\u003cmeta data-mint-head name=\"keywords\" content=\"country state city API, countries API, states API, cities API, ISO 3166, geographical database, location dropdown\">\u003cmeta data-mint-head name=\"application-name\" content=\"Country State City Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"GraphQL API - Country State City Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"Query countries, states, cities, regions, and subregions with GraphQL instead of REST\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Country State City Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.countrystatecity.in/api/graphql\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://docs.countrystatecity.in/images/hero-light.png\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"GraphQL API - Country State City Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Query countries, states, cities, regions, and subregions with GraphQL instead of REST\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://docs.countrystatecity.in/images/hero-light.png\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/webbywonder/QCoQSc7Hfg85lHKO/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Country State City Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#2563EB\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.countrystatecity.in/api/graphql\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api/graphql.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.countrystatecity.in/#organization\",\"name\":\"Country State City Documentation\",\"url\":\"https://docs.countrystatecity.in\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/webbywonder/DXb6lzT49e7Mz1Kh/logo/csc-docs-logo-dark.svg?fit=max\u0026auto=format\u0026n=DXb6lzT49e7Mz1Kh\u0026q=85\u0026s=893eeadd293f0443a7f2b192eb9b59d0\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.countrystatecity.in#website\",\"name\":\"Country State City Documentation\",\"url\":\"https://docs.countrystatecity.in\",\"publisher\":{\"@id\":\"https://docs.countrystatecity.in/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.countrystatecity.in/api/graphql#webpage\",\"url\":\"https://docs.countrystatecity.in/api/graphql\",\"name\":\"GraphQL API\",\"description\":\"Query countries, states, cities, regions, and subregions with GraphQL instead of REST\",\"dateModified\":\"2026-09-29T14:12:46.502Z\",\"isPartOf\":{\"@id\":\"https://docs.countrystatecity.in#website\"},\"breadcrumb\":{\"@id\":\"https://docs.countrystatecity.in/api/graphql#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.countrystatecity.in/api/graphql#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Country State City Documentation\",\"item\":\"https://docs.countrystatecity.in\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"GraphQL API\",\"item\":\"https://docs.countrystatecity.in/api/graphql\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.countrystatecity.in/api/graphql#apireference\",\"headline\":\"GraphQL API\",\"name\":\"GraphQL API\",\"description\":\"Query countries, states, cities, regions, and subregions with GraphQL instead of REST\",\"url\":\"https://docs.countrystatecity.in/api/graphql\",\"mainEntityOfPage\":{\"@id\":\"https://docs.countrystatecity.in/api/graphql#webpage\"},\"image\":\"https://docs.countrystatecity.in/images/hero-light.png\",\"dateModified\":\"2026-09-29T14:12:46.502Z\",\"publisher\":{\"@id\":\"https://docs.countrystatecity.in/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.countrystatecity.in#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Country State City Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Country State City Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api/graphql.md","siteName":"Country State City Documentation","nav":{"global":null,"tabs":[{"tab":"Home","pages":[{"title":"Home","href":""}]},{"tab":"API Guides","icon":"book","pages":[{"title":"API Guides","href":"/api/introduction"}]},{"tab":"API Reference","icon":"code","groups":[{"group":"Countries","icon":"earth-americas","pages":[{"title":"Get All Countries","openapi":"GET /countries","href":"/api/endpoints/get-all-countries"},{"title":"Get Country Details","openapi":"GET /countries/{ciso}","href":"/api/endpoints/get-country-details"}]},{"group":"States","icon":"map","pages":[{"title":"Get All States","openapi":"GET /states","href":"/api/endpoints/get-all-states"},{"title":"Get States by Country","openapi":"GET /countries/{ciso}/states","href":"/api/endpoints/get-states-by-country"},{"title":"Get State Details","openapi":"GET /countries/{ciso}/states/{siso}","href":"/api/endpoints/get-state-details"}]},{"group":"Cities","icon":"city","pages":[{"title":"Get Cities by Country","openapi":"GET /countries/{ciso}/cities","href":"/api/endpoints/get-cities-by-country"},{"title":"Get Cities by State","openapi":"GET /countries/{ciso}/states/{siso}/cities","href":"/api/endpoints/get-cities-by-state"}]},{"group":"Postcodes","icon":"envelope","pages":[{"title":"Get Postcode by Code","openapi":"GET /countries/{ciso}/postcodes/{code}","href":"/api/endpoints/get-postcode-by-code"},{"title":"Get Postcodes by Country","openapi":"GET /countries/{ciso}/postcodes","href":"/api/endpoints/get-postcodes-by-country"}]},{"group":"Regions","icon":"globe","pages":[{"title":"Get All Regions","openapi":"GET /regions","href":"/api/endpoints/get-all-regions"},{"title":"Get Region Details","openapi":"GET /regions/{id}","href":"/api/endpoints/get-region-details"},{"title":"Get Subregions by Region","openapi":"GET /regions/{id}/subregions","href":"/api/endpoints/get-subregions-by-region"},{"title":"Get Subregion Details","openapi":"GET /subregions/{id}","href":"/api/endpoints/get-subregion-details"},{"title":"Get Countries by Subregion","openapi":"GET /subregions/{id}/countries","href":"/api/endpoints/get-countries-by-subregion"}]},{"group":"Timezones","icon":"clock","pages":[{"title":"Get Timezone by Country","openapi":"GET /timezone/{ciso}","href":"/api/endpoints/get-timezone-by-country"},{"title":"Get Timezone by State","openapi":"GET /timezone/{ciso}/{siso}","href":"/api/endpoints/get-timezone-by-state"},{"title":"Get Timezone by City","openapi":"GET /timezone/{ciso}/{siso}/{city_id}","href":"/api/endpoints/get-timezone-by-city"}]},{"group":"Currencies","icon":"coins","pages":[{"title":"List All Currencies","openapi":"GET /currency","href":"/api/endpoints/list-all-currencies"},{"title":"Get Currency by Country","openapi":"GET /currency/{ciso}","href":"/api/endpoints/get-currency-by-country"}]},{"group":"Phone","icon":"phone","pages":[{"title":"List Dial Codes","openapi":"GET /phone","href":"/api/endpoints/list-dial-codes"},{"title":"Get Dial Code by Country","openapi":"GET /phone/{ciso}","href":"/api/endpoints/get-dial-code-by-country"},{"title":"Parse Phone Number","openapi":"GET /phone/parse","href":"/api/endpoints/parse-phone-number"}]},{"group":"ISO Codes","icon":"hashtag","pages":[{"title":"Lookup Country by ISO Code","openapi":"GET /iso/country","href":"/api/endpoints/lookup-country-by-iso"},{"title":"Lookup State by ISO Code","openapi":"GET /iso/state","href":"/api/endpoints/lookup-state-by-iso"},{"title":"Convert ISO Code","openapi":"GET /iso/country/convert","href":"/api/endpoints/convert-iso-code"}]},{"group":"Search","icon":"magnifying-glass","pages":[{"title":"Fuzzy Search","openapi":"GET /search/fuzzy","href":"/api/endpoints/fuzzy-search"},{"title":"Autocomplete","openapi":"GET /search/autocomplete","href":"/api/endpoints/get-search-autocomplete"},{"title":"Nearby Search","openapi":"GET /search/nearby","href":"/api/endpoints/get-search-nearby"}]},{"group":"Data Changes","icon":"code-compare","pages":[{"title":"Data Change Feed","openapi":"GET /changes","description":"Keep your copy of Country State City data current without downloading the full dataset again","href":"/api/endpoints/get-data-changes"}]},{"group":"GraphQL API","icon":"diagram-project","pages":[{"title":"GraphQL API","api":"POST https://api.countrystatecity.in/v1/graphql","href":"/api/graphql"}]},{"group":"Meta","icon":"circle-info","pages":[{"title":"Get Data Version","openapi":"GET /meta/data-version","description":"Check which geographic data release your API responses are currently served from","href":"/api/endpoints/get-data-version"}]}]},{"tab":"Tools","pages":[{"title":"Tools","href":"/tools/overview"}]},{"tab":"Database","pages":[{"title":"Database","href":"/database/overview"}]}]},"basePath":"","title":"GraphQL API - Country State City Documentation","buildId":"dpl_715YoAgvjTGBDdo8RtXmHKM22b5p","deploymentId":"dpl_715YoAgvjTGBDdo8RtXmHKM22b5p","dynamics":["10e4515597","c2aa737661","2b790eda92","b0f84f53ff"],"chunks":["BannerMarkdown-DwP8r2Xt.js","dist-r2tNEC1n.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","clsx-BNa-H6W6.js","html-void-elements-mCSPHezU.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","OpenApiReferenceProvider-BvKnMd7F.js","utils-BMt52org.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-CGXZuDGO.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-Dl57XWH2.js","snippetPresets-CWd8CxSk.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","conditional-requirements-CFM0id0Q.js","ApiExamples-BR-Wkc_D.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-YMmi08aZ.js","shallow-DBC1OB78.js","getApiPlaygroundDisplay-Be7mmEzP.js","CodeSnippet-B14o1TgQ.js","CodeSnippets-CJ2q3fTq.js","Page-Chgj7sZe.js","getPastedJson-DnpLXm8x.js","icon-BpkSFtdK.js","MethodPill-BO3zPf-g.js","DuplicateIcon-Bib3qwfw.js","createIcon-CY2noFo3.js","DynamicMarkdown-TAXIW2vN.js","SectionHeading-Dfs3Fmfw.js","axios-vUo_bRtp.js"]}