States of every country request - parameters

The Javascript and PHP classes provided in the sample code should take care of the endpoint and the headers for you. It is helpful to understand them in case you need to write any custom code that we haven't provided.

Endpoint

For this API request, you will need to hit the following endpoint.

https://www.air-port-codes.com/api/v1/states

Headers

In order to be granted access to the API, all of your requests must include an APC-Auth header that includes your API Key. An APC-Auth-Secret header can also be supplied for special cases where a referrer cannot be found, however, in most cases it will not be necessary.

Name Action Description
APC-Auth Required Your unique 10 digit alphanumeric Air-Port-Codes API key. This can be located in your account settings.
APC-Auth-Secret Optional Your unique 15 digit alphanumeric Air-Port-Codes API secret. You should NOT need to use this from Javascript unless you are running the script outside of a server, from an app or local testing (file://...). In most cases you won't need to use this if you add a proper domain to your account. It is more secure without it!

Parameters

This is a list of the required and optional parameters that can help you retrieve the desired response.

Name Action Description
country Required This should be the 2-letter iso value of a desired country.
field_name Optional Use this if you want the response to be returned with the select html tag wrapping it with the name attribute being set to this value. This is useful, especially when the country doesn't have any states associated with it, an input field will be returned instead of a select field.
is_select_options Optional This will return the countries object as a string of options for a select tag, rather than an array of objects, if it is set to true.
autoselect_visitor_location Optional Allows you to have the visitors country auto selected in a select field.
selected Optional This will select the specified country in the select field.
ip_address Optional You can pass in an ip address and have the select field auto selected to the ip address' country.