{
  "openapi": "3.1.0",
  "info": {
    "title": "mackan.eu Bolagsverket API",
    "description": "Free proxy API for Swedish company data from Bolagsverket (Swedish Companies Registration Office). No API key, no registration, no rate limit for reasonable use. Data covers all ~1.2 million registered Swedish companies.",
    "version": "3.9.2",
    "contact": {
      "email": "kontakt@mackan.eu",
      "url": "https://mackan.eu/tools/bolagsverket/"
    },
    "license": {
      "name": "CC-BY-4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    }
  },
  "servers": [
    {
      "url": "https://mackan.eu/tools/bolagsverket",
      "description": "Production"
    }
  ],
  "paths": {
    "/get_data.php": {
      "get": {
        "operationId": "getCompanyByOrgnr",
        "summary": "Look up company by organization number",
        "description": "Returns full company data from Bolagsverket for a given Swedish organization number (organisationsnummer). Includes company name, registered address, legal form, registration date, board members, SNI industry codes, and links to annual reports (årsredovisningar). Proxies the official Bolagsverket API — data is authoritative and real-time.",
        "parameters": [
          {
            "name": "orgnr",
            "in": "query",
            "required": true,
            "description": "Swedish organization number, 10 digits, with or without hyphen",
            "schema": {
              "type": "string",
              "pattern": "^\\d{6}-?\\d{4}$",
              "examples": ["5560747551", "556074-7551", "8026702664"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Company data from Bolagsverket",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "organisationer": {
                      "type": "array",
                      "description": "Array with one organisation object",
                      "items": {
                        "$ref": "#/components/schemas/Organisation"
                      }
                    }
                  }
                },
                "example": {
                  "organisationer": [
                    {
                      "identitetsbeteckning": "5560747551",
                      "foretagsnamn": [{"namn": "INGKA HOLDING SVERIGE AB"}],
                      "foretagsform": {"kod": "AB-ORGFO", "klartext": "Aktiebolag"},
                      "status": {"kod": "REGI", "klartext": "Registrerad"},
                      "registreringsdatum": "1991-04-17"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid organization number format",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "404": {
            "description": "Organization number not found in Bolagsverket"
          },
          "502": {
            "description": "Upstream Bolagsverket API unavailable"
          }
        }
      }
    },
    "/search_name.php": {
      "get": {
        "operationId": "searchCompaniesByName",
        "summary": "Search companies by name",
        "description": "Full-text search across all ~1.2 million Swedish companies by name. Returns up to 8 results sorted by relevance and active status. Uses a local database synchronized from the Bolagsverket bulk dataset. Useful for finding an organization number when only the company name is known.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Company name or partial name",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 200,
              "examples": ["IKEA", "Vattenfall", "Nordic Tech Solutions"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "maxItems": 8,
                      "items": { "$ref": "#/components/schemas/CompanySearchResult" }
                    },
                    "mode": {
                      "type": "string",
                      "enum": ["exact", "menade_du", "empty"],
                      "description": "exact = all query words matched; menade_du = partial/fuzzy match (did you mean?); empty = no results"
                    },
                    "request_id": { "type": "string" }
                  }
                },
                "example": {
                  "results": [
                    {
                      "orgnr": "5560747551",
                      "name": "INGKA HOLDING SVERIGE AB",
                      "extra_names": [],
                      "form": "AB",
                      "active": true,
                      "city": "MALMÖ",
                      "reg_year": 1991
                    }
                  ],
                  "mode": "exact",
                  "request_id": "a1b2c3d4"
                }
              }
            }
          }
        }
      }
    },
    "/search_address.php": {
      "get": {
        "operationId": "searchCompaniesByAddress",
        "summary": "Search companies by address or industry",
        "description": "Find Swedish companies by street address, city, postal code, or industry/business description. Both addr and branch are optional but at least one must be provided. Returns up to 500 results sorted by relevance. Useful for finding all companies at a specific location or all companies in a given industry in a city.",
        "parameters": [
          {
            "name": "addr",
            "in": "query",
            "required": false,
            "description": "Street address, city name, or postal code",
            "schema": {
              "type": "string",
              "examples": ["Drottninggatan Stockholm", "50332", "Storgatan Borås"]
            }
          },
          {
            "name": "branch",
            "in": "query",
            "required": false,
            "description": "Industry or business activity keyword (Swedish)",
            "schema": {
              "type": "string",
              "examples": ["restaurang", "bygg", "konsult", "IT"]
            }
          },
          {
            "name": "form",
            "in": "query",
            "required": false,
            "description": "Filter by legal form",
            "schema": {
              "type": "string",
              "enum": ["AB", "HB", "KB", "EK", "E", "I", "BRF", "S", "FL"],
              "description": "AB=Aktiebolag, HB=Handelsbolag, KB=Kommanditbolag, EK=Ekonomisk förening, E=Enskild firma, I=Ideell förening, BRF=Bostadsrättsförening, S=Stiftelse, FL=Filial"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "description": "1 = active companies only (default), 0 = include inactive/dissolved",
            "schema": {
              "type": "integer",
              "enum": [0, 1],
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum results to return (1–500, default 20)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching companies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/CompanyAddressResult" }
                    },
                    "total": {
                      "type": "integer",
                      "description": "Total matching records in database (may exceed shown)"
                    },
                    "shown": {
                      "type": "integer",
                      "description": "Number of records in this response"
                    },
                    "request_id": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Organisation": {
        "type": "object",
        "description": "Full company record as returned by Bolagsverket API",
        "properties": {
          "identitetsbeteckning": {
            "type": "string",
            "description": "Organization number, 10 digits"
          },
          "foretagsnamn": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "namn": { "type": "string" },
                "typ": { "type": "string" }
              }
            }
          },
          "foretagsform": {
            "type": "object",
            "properties": {
              "kod": { "type": "string", "example": "AB-ORGFO" },
              "klartext": { "type": "string", "example": "Aktiebolag" }
            }
          },
          "status": {
            "type": "object",
            "properties": {
              "kod": { "type": "string", "example": "REGI" },
              "klartext": { "type": "string", "example": "Registrerad" }
            }
          },
          "registreringsdatum": {
            "type": "string",
            "format": "date",
            "description": "Registration date"
          },
          "adress": {
            "type": "object",
            "description": "Registered address"
          },
          "styrelseledamoter": {
            "type": "array",
            "description": "Board members"
          },
          "sniKoder": {
            "type": "array",
            "description": "SNI industry codes (Swedish Standard Industrial Classification)"
          },
          "handlingar": {
            "type": "array",
            "description": "Filed documents (annual reports etc.)"
          }
        }
      },
      "CompanySearchResult": {
        "type": "object",
        "properties": {
          "orgnr": {
            "type": "string",
            "description": "Organization number, 10 digits",
            "example": "5560747551"
          },
          "name": {
            "type": "string",
            "description": "Primary registered company name",
            "example": "INGKA HOLDING SVERIGE AB"
          },
          "extra_names": {
            "type": "array",
            "description": "Secondary or trade names",
            "items": { "type": "string" }
          },
          "form": {
            "type": "string",
            "description": "Legal form label",
            "example": "AB"
          },
          "active": {
            "type": "boolean",
            "description": "Whether the company is currently registered and active"
          },
          "city": {
            "type": "string",
            "description": "Registered city",
            "example": "MALMÖ"
          },
          "reg_year": {
            "type": "integer",
            "description": "Year of registration",
            "example": 1991
          }
        }
      },
      "CompanyAddressResult": {
        "type": "object",
        "properties": {
          "orgnr": { "type": "string" },
          "name": { "type": "string" },
          "form": { "type": "string" },
          "active": { "type": "boolean" },
          "city": { "type": "string" },
          "zip": { "type": "string" },
          "address": { "type": "string" },
          "description": {
            "type": "string",
            "description": "Business activity description, max 140 characters"
          },
          "reg_year": { "type": "integer" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "message": { "type": "string" }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Interactive tool",
    "url": "https://mackan.eu/tools/bolagsverket/"
  }
}
