 The convenient location of the port and its independence as a city and state for centuries strengthened this position.The city was member in the medieval Hanseatic trading league and a free imperial city of the Holy Roman Empire.From 1815 until 1866 Hamburg was an independent and sovereign state of the German Confederation, then the North German Confederation (1866–71), the German Empire (1871–1918) and during the period of the Weimar Republic (1918–33).