{
  "openapi": "3.1.0",
  "info": {
    "title": "Baby Names API",
    "version": "1.0.0",
    "description": "Popularity, gender split and year-by-year trends for every US baby name since 1880.\n\nPopularity, gender split, and year-by-year trends for baby names, backed by the full US Social Security Administration dataset (every name × year × gender since 1880). Look up a name, get the top names for any year, chart a name's popularity over time, or pull a random name.",
    "contact": {
      "name": "Data and APIs",
      "url": "https://dataandapis.com/contact"
    },
    "termsOfService": "https://dataandapis.com/terms-of-service",
    "license": {
      "name": "Data and APIs Terms of Service",
      "url": "https://dataandapis.com/terms-of-service"
    },
    "x-logo": {
      "url": "https://dataandapis.com/images/baby-names.webp"
    }
  },
  "externalDocs": {
    "description": "Documentation, live tester and pricing",
    "url": "https://dataandapis.com/apis/baby-names"
  },
  "servers": [
    {
      "url": "https://api-baby-names.dataandapis.com"
    }
  ],
  "tags": [
    {
      "name": "Data",
      "description": "Baby Names API belongs to the Data category of the Data and APIs catalog."
    }
  ],
  "paths": {
    "/v1/names/{name}": {
      "get": {
        "operationId": "getName",
        "summary": "Get Name",
        "description": "Get Name endpoint of the Baby Names API. Costs 2 tokens per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/baby-names/get-name"
        },
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "Emma"
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "1990"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "name": "Emma",
                  "by_gender": {
                    "F": {
                      "total_count": 1023456,
                      "first_year": 1880,
                      "last_year": 2023,
                      "peak_year": 2003,
                      "peak_count": 25562,
                      "best_rank": 1,
                      "latest": {
                        "year": 2023,
                        "count": 14376,
                        "rank": 2
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/names/trend/{name}": {
      "get": {
        "operationId": "nameTrend",
        "summary": "Name Trend",
        "description": "Name Trend endpoint of the Baby Names API. Costs 2 tokens per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/baby-names/name-trend"
        },
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "Emma"
          },
          {
            "name": "gender",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "F"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "name": "Emma",
                  "gender": "F",
                  "points": [
                    {
                      "year": 2000,
                      "count": 12305,
                      "rank": 17
                    },
                    {
                      "year": 2003,
                      "count": 25562,
                      "rank": 1
                    },
                    {
                      "year": 2023,
                      "count": 14376,
                      "rank": 2
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/names/random": {
      "get": {
        "operationId": "randomName",
        "summary": "Random Name",
        "description": "Random Name endpoint of the Baby Names API. Costs 2 tokens per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/baby-names/random-name"
        },
        "parameters": [
          {
            "name": "gender",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "F"
          },
          {
            "name": "starts_with",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "A"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "name": "Aaliyah",
                  "sex": "F",
                  "year": 2023,
                  "count": 1234,
                  "rank": 58
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/names/top": {
      "get": {
        "operationId": "topNames",
        "summary": "Top Names",
        "description": "Top Names endpoint of the Baby Names API. Costs 2 tokens per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/baby-names/top-names"
        },
        "parameters": [
          {
            "name": "gender",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "F"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "100"
          },
          {
            "name": "year",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "1990"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "year": 1990,
                  "gender": "F",
                  "count": 3,
                  "names": [
                    {
                      "name": "Jessica",
                      "count": 46466,
                      "rank": 1
                    },
                    {
                      "name": "Ashley",
                      "count": 45554,
                      "rank": 2
                    },
                    {
                      "name": "Emily",
                      "count": 24379,
                      "rank": 3
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Create a free key at https://dataandapis.com/sign-up. 500 tokens a month on the Free plan; this API costs 2 tokens per call."
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ]
}