Skip to main content

States API (1.0)

Download OpenAPI specification:Download

This API was created as a final project for INF653 at Fort Hays State University. It enables you to retrieve, add, update and delete specific data points about a single US state, or all of them.

All endpoints allow you to retrieve and edit various attributes about US states, such as population, nickname, and date of admission. Responses are returned in JSON.

All states

Get all state data

Retrieves all state data elements for all states in the US.

query Parameters
contig
boolean

If set to true, returns data for contiguous states (Not AK or HI). If set to false, returns data for AK and HI.

Responses

Response samples

Content type
application/json
Example
[]

Single state

Get data for a single state

Retrieves all data for a single US state.

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Responses

Response samples

Content type
{}

Add a fun fact

Adds one or more fun facts to the given state data object

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Request Body schema: application/json

The required body is an array of strings. Array elements are NOT checked for duplication and will be added to the database as-is.

funfacts
required
Array of strings

An array of one or more fun facts

Responses

Request samples

Content type
application/json
{
  • "funfacts": [
    ]
}

Response samples

Content type
application/json
{
  • "_id": "626882ec0af8cc1cb6b19418",
  • "stateCode": "KS",
  • "funfacts": [
    ],
  • "__v": 65
}

Replace a fun fact

Replaces a state's fun fact. You must specify the index of the fun facts array element in your request body. The fun facts array is NOT zero-indexed (i.e. The first element in the array is referenced by "1" and not "0."

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Request Body schema: application/json

The fun fact at the specified index will be replaced.

index
required
string
funfact
required
string

Responses

Request samples

Content type
application/json
{
  • "index": "1",
  • "funfact": "The state bug is the honeybee."
}

Response samples

Content type
application/json
{
  • "_id": "626882ec0af8cc1cb6b19418",
  • "stateCode": "KS",
  • "funfacts": [
    ],
  • "__v": 67
}

Delete a fun fact

Deletes a state's fun fact. You must specify the index of the fun facts array element in your request body. The fun facts array is NOT zero-indexed (i.e. The first element in the array is referenced by "1" and not "0."

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Request Body schema:

Specify the index of the fun fact to be deleted.

index
string

Responses

Request samples

Content type
{
  • "index": "1"
}

Response samples

Content type
application/json
{
  • "_id": "626882ec0af8cc1cb6b19418",
  • "stateCode": "KS",
  • "funfacts": [
    ],
  • "__v": 69
}

Get random fun fact

Retrieves a random fun fact for a state

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Responses

Response samples

Content type
application/json
{
  • "funfact": "The state bird is the Western Meadowlark"
}

Get state capital

Retrieves the capital of the given state.

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Responses

Response samples

Content type
application/json
{
  • "state": "Kansas",
  • "capital": "Topeka"
}

Get state nickname

Retrieves the capital of the given state.

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Responses

Response samples

Content type
application/json
{
  • "state": "Kansas",
  • "nickname": "Sunflower State"
}

Get state population

Retrieves the population of the given state.

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Responses

Response samples

Content type
application/json
{
  • "state": "Kansas",
  • "population": "2,893,957"
}

Get state admission date

Retrieves the admission date for the given state.

path Parameters
state
required
string

Two-letter state abbreviation (not case sensitive)

Responses

Response samples

Content type
application/json
{
  • "state": "Kansas",
  • "admitted": "1861-01-29"
}