[go: up one dir, main page]

0% found this document useful (0 votes)
5 views55 pages

103616

The document provides information about the book 'Django for APIs' by William S. Vincent, which teaches readers how to build web APIs using Python and Django. It covers essential concepts such as RESTful APIs, Django REST Framework, and includes practical examples like a Library website and Todo API. The book is designed for beginners and aims to simplify the learning process of creating web APIs with Django.

Uploaded by

hkokpxgh0789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views55 pages

103616

The document provides information about the book 'Django for APIs' by William S. Vincent, which teaches readers how to build web APIs using Python and Django. It covers essential concepts such as RESTful APIs, Django REST Framework, and includes practical examples like a Library website and Todo API. The book is designed for beginners and aims to simplify the learning process of creating web APIs with Django.

Uploaded by

hkokpxgh0789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Django for APIs Build web APIs with Python and

Django William S Vincent download pdf

https://ebookultra.com/download/django-for-apis-build-web-apis-with-
python-and-django-william-s-vincent/

Visit ebookultra.com today to download the complete set of


ebook or textbook!
We believe these products will be a great fit for you. Click
the link to download now, or visit ebookultra.com
to discover even more!

Django for Beginners 4.0 Edition William S. Vincent

https://ebookultra.com/download/django-for-beginners-4-0-edition-
william-s-vincent/

Django for Beginners 3 1 3.1 Edition William S. Vincent

https://ebookultra.com/download/django-for-beginners-3-1-3-1-edition-
william-s-vincent/

RESTful Web APIs 1st Edition Leonard Richardson

https://ebookultra.com/download/restful-web-apis-1st-edition-leonard-
richardson/

Two Scoops of Django Best Practices For Django 1 5 1st


Edition Daniel Greenfeld

https://ebookultra.com/download/two-scoops-of-django-best-practices-
for-django-1-5-1st-edition-daniel-greenfeld/
Pro Django 2nd Edition Marty Alchin

https://ebookultra.com/download/pro-django-2nd-edition-marty-alchin/

Practical Django Projects Second Edition James Bennett

https://ebookultra.com/download/practical-django-projects-second-
edition-james-bennett/

PayPal APIs Up and Running Second Edition Matthew A.


Russell

https://ebookultra.com/download/paypal-apis-up-and-running-second-
edition-matthew-a-russell/

Bluetooth Application Programming with the Java APIs The


Morgan Kaufmann Series in Networking 1st Edition C Bala
Kumar
https://ebookultra.com/download/bluetooth-application-programming-
with-the-java-apis-the-morgan-kaufmann-series-in-networking-1st-
edition-c-bala-kumar/

Flask Web Development Developing Web Applications With


Python 2nd Edition Miguel Grinberg

https://ebookultra.com/download/flask-web-development-developing-web-
applications-with-python-2nd-edition-miguel-grinberg/
Django for APIs Build web APIs with Python and Django
William S Vincent Digital Instant Download
Author(s): William S Vincent
ISBN(s): 9781735467221, 1735467227
Edition: Paperback
File Details: PDF, 5.35 MB
Year: 2020
Language: english
Django for APIs

Build web APIs with Python and Django

William S. Vincent

This book is for sale at http://leanpub.com/djangoforapis

This version was published on 2020-08-13

This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing
process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools
and many iterations to get reader feedback, pivot until you have the right book and build
traction once you do.

© 2018 - 2020 William S. Vincent


Also By William S. Vincent
Django for Beginners

Django for Professionals


Contents

Introduction 1
Prerequisites 1
Why APIs 2
Django REST Framework 3
Why this book 4
Conclusion 4

Chapter 1: Web APIs 5


World Wide Web 5
URLs 6
Internet Protocol Suite 7
HTTP Verbs 8
Endpoints 8
HTTP 9
Status Codes 11
Statelessness 12
REST 12
Conclusion 13

Chapter 2: Library Website and API 14


Traditional Django 14
First app 17
Models 19
Admin 21
Views 24
CONTENTS

URLs 24
Webpage 27
Django REST Framework 28
URLs 29
Views 30
Serializers 31
cURL 32
Browsable API 33
Conclusion 34

Chapter 3: Todo API 36


Initial Set Up 36
Models 40
Django REST Framework 42
URLs 44
Serializers 45
Views 46
Consuming the API 48
Browsable API 48
CORS 50
Tests 53
Conclusion 54

Chapter 4: Todo React Front-end 56


Install Node 56
Install React 57
Mock data 59
Django REST Framework + React 63
Conclusion 66

Chapter 5: Blog API 67


Initial Set Up 67
Model 68
CONTENTS

Tests 72
Django REST Framework 73
URLs 74
Serializers 76
Views 77
Browsable API 78
Conclusion 82

Chapter 6: Permissions 83
Create a new user 83
Add log in to the browsable API 86
AllowAny 90
View-Level Permissions 92
Project-Level Permissions 94
Custom permissions 95
Conclusion 99

Chapter 7: User Authentication 100


Basic Authentication 100
Session Authentication 102
Token Authentication 103
Default Authentication 105
Implementing token authentication 106
Endpoints 108
dj-rest-auth 109
User Registration 114
Tokens 118
Conclusion 123

Chapter 8: Viewsets and Routers 125


User endpoints 125
Viewsets 131
Routers 132
CONTENTS

Conclusion 138

Chapter 9: Schemas and Documentation 139


Schemas 140
Documentation 142
Conclusion 146

Conclusion 147
Next Steps 147
Giving Thanks 148
Introduction
The internet is powered by RESTful APIs. Behind the scenes even the simplest online task involves
multiple computers interacting with one another.

An API (Application Programming Interface) is a formal way to describe two computers commu-
nicating directly with one another. And while there are multiple ways to build an API, web APIs—
which allow for the transfer of data over the world wide web—are overwhelmingly structured in
a RESTful (REpresentational State Transfer) pattern.

In this book you will learn how to build multiple RESTful web APIs of increasing complexity from
scratch using Django1 and Django REST Framework2 , one of the most popular and customizable
ways to build web APIs, used by many of the largest tech companies in the world including Insta-
gram, Mozilla, Pinterest, and Bitbucket. This approach is also uniquely well-suited to beginners
because Django’s “batteries-included” approach masks much of the underlying complexity and
security risks involved in creating any web API.

Prerequisites

If you’re brand new to web development with Django, I recommend first reading my previous
book Django for Beginners3 . The first several chapters are available for free online and cover
proper set up, a Hello World app, and a Pages app. The full-length version goes deeper and
covers a Blog website with forms and user accounts as well as a production-ready Newspaper
site that features a custom user model, complete user authentication flow, emails, permissions,
deployment, environment variables, and more.

This background in traditional Django is important since Django REST Framework deliberately
mimics many Django conventions.
1
https://www.djangoproject.com/
2
http://www.django-rest-framework.org/
3
https://djangoforbeginners.com/
Introduction 2

It is also recommended that readers have a basic knowledge of Python itself. Truly mastering
Python takes years, but with just a little bit of knowledge you can dive right in and start building
things.

Why APIs

Django was first released in 2005 and at the time most websites consisted of one large monolithic
codebase. The “back-end” consisted of database models, URLs, and views which interacted with
the “front-end” templates of HTML, CSS, and JavaScript that controlled the presentational layout
of each web page.

However in recent years an “API-first” approach has emerged as arguably the dominant paradigm
in web development. This approach involves formally separating the back-end from the front-
end. It means Django becomes a powerful database and API instead of just a website framework.

Today Django is arguably used more often as just a back-end API rather than a full monolithic
website solution at large companies!

An obvious question at this point is, “Why bother?” Traditional Django works quite well on its own
and transforming a Django site into a web API seems like a lot of extra work. Plus, as a developer,
you then have to write a dedicated front-end in another programming language.

This approach of dividing services into different components, by the way, is broadly known as
Service-oriented architecture4 .

It turns out however that there are multiple advantages to separating the front-end from
the back-end. First, it is arguably much more “future-proof” because a back-end API can be
consumed by any JavaScript front-end. Given the rapid rate of change in front-end libraries–
React5 was only released in 2013 and Vue6 in 2014!–this is highly valuable. When the current
front-end frameworks are eventually replaced by even newer ones in the years to come, the
back-end API can remain the same. No major rewrite is required.

Second, an API can support multiple front-ends written in different languages and frameworks.
Consider that JavaScript is used for web front-ends, while Android apps require the Java
4
https://en.wikipedia.org/wiki/Service-oriented_architecture
5
https://reactjs.org/
6
https://vuejs.org/
Introduction 3

programming language, and iOS apps need the Swift programming language. With a traditional
monolithic approach, a Django website cannot support these various front-ends. But with an
internal API, all three can communicate with the same underlying database back-end!

Third, an API-first approach can be used both internally and externally. When I worked at
Quizlet7 back in 2010, we did not have the resources to develop our own iOS or Android apps.
But we did have an external API available that more than 30 developers used to create their own
flashcard apps powered by the Quizlet database. Several of these apps were downloaded over
a million times, enriching the developers and increasing the reach of Quizlet at the same time.
Quizlet is now a top 20 website in the U.S. during the school year.

The major downside to an API-first approach is that it requires more configuration than a
traditional Django application. However as we will see in this book, the fantastic Django REST
Framework library removes much of this complexity.

Django REST Framework

There are hundreds and hundreds of third-party apps available that add further functionality to
Django. You can see a complete, searchable list over at Django Packages8 , as well as a curated
list in the awesome-django repo9 . However, among all third-party applications, Django REST
Framework is arguably the killer app for Django. It is mature, full of features, customizable,
testable, and extremely well-documented. It also purposefully mimics many of Django’s tra-
ditional conventions, which makes learning it much faster. And it is written in the Python
programming language, a wonderful, popular, and accessible language.

If you already know Django, then learning Django REST Framework is a logical next step. With a
minimal amount of code, it can transform any existing Django application into a web API.
7
https://quizlet.com/
8
https://djangopackages.org/
9
https://github.com/wsvincent/awesome-django
Introduction 4

Why this book

I wrote this book because there is a distinct lack of good resources available for developers
new to Django REST Framework. The assumption seems to be that everyone already knows all
about APIs, HTTP, REST, and the like. My own journey in learning how to build web APIs was
frustrating… and I already knew Django well enough to write a book on it!

This book is the guide I wish existed when starting out with Django REST Framework.

Chapter 1 begins with a brief introduction to web APIs and the HTTP protocol. In Chapter 2 we
review the differences between traditional Django and Django REST Framework by building out
a Library book website and then adding an API to it. Then in Chapters 3-4 we build a Todo API
and connect it to a React front-end. The same process can be used to connect any dedicated
front-end (web, iOS, Android, desktop, or other) to a web API back-end.

In Chapters 5-9 we build out a production-ready Blog API which includes full CRUD functionality.
We also cover in-depth permissions, user authentication, viewsets, routers, documentation, and
more.

Complete source code for all chapters can be found online on Github10 .

Conclusion

Django and Django REST Framework is a powerful and accessible way to build web APIs. By the
end of this book you will be able to build your own web APIs from scratch properly using modern
best practices. And you’ll be able to extend any existing Django website into a web API with a
minimal amount of code.

Let’s begin!
10
https://github.com/wsvincent/restapiswithdjango
Chapter 1: Web APIs
Before we start building our own web APIs it’s important to review how the web really works.
After all, a “web API” literally sits on top of the existing architecture of the world wide web and
relies on a host of technologies including HTTP, TCP/IP, and more.

In this chapter we will review the basic terminology of web APIs: endpoints, resources, HTTP
verbs, HTTP status codes, and REST. Even if you already feel comfortable with these terms, I
encourage you to read the chapter in full.

World Wide Web

The Internet is a system of interconnected computer networks that has existed since at least the
1960s11 . However, the internet’s early usage was restricted to a small number of isolated networks,
largely government, military, or scientific in nature, that exchanged information electronically.
By the 1980s, many research institutes and universities were using the internet to share data.
In Europe, the biggest internet node was located at CERN (European Organization for Nuclear
Research) in Geneva, Switzerland, which operates the largest particle physics laboratory in the
world. These experiments generate enormous quantities of data that need to be shared remotely
with scientists all around the world.

Compared with today, though, overall internet usage in the 1980s was miniscule. Most people
did not have access to it or even understood why it mattered. A small number of internet
nodes powered all the traffic and the computers using it were primarily within the same, small
networks.

This all changed in 1989 when a research scientist at CERN, Tim Berners-Lee, invented HTTP
and ushered in the modern World Wide Web. His great insight was that the existing hypertext12
11
https://en.wikipedia.org/wiki/Internet
12
https://en.wikipedia.org/wiki/Hypertext
Chapter 1: Web APIs 6

system, where text displayed on a computer screen contained links (hyperlinks) to other
documents, could be moved onto the internet.

His invention, Hypertext Transfer Protocol (HTTP)13 , was the first standard, universal way to
share documents over the internet. It ushered in the concept of web pages: discrete documents
with a URL, links, and resources such as images, audio, or video.

Today, when most people think of “the internet,” they think of the World Wide Web, which is now
the primary way that billions of people and computers communicate online.

URLs

A URL (Uniform Resource Locator) is the address of a resource on the internet. For example, the
Google homepage lives at https://www.google.com.

When you want to go to the Google homepage, you type the full URL address into a web browser.
Your browser then sends a request out over the internet and is magically connected (we’ll cover
what actually happens shortly) to a server that responds with the data needed to render the
Google homepage in your browser.

This request and response pattern is the basis of all web communication. A client (typically a
web browser but also a native app or really any internet-connected device) requests information
and a server responds with a response.

Since web communication occurs via HTTP these are known more formally as HTTP requests
and HTTP responses.

Within a given URL are also several discrete components. For example, consider the Google
homepage located at https://www.google.com. The first part, https, refers to the scheme used.
It tells the web browser how to access resources at the location. For a website this is typically
http or https, but it could also be ftp for files, smtp for email, and so on. The next section,

www.google.com, is the hostname or the actual name of the site. Every URL contains a scheme

and a host.

Many webpages also contain an optional path, too. If you go to the homepage for Python
13
https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
Chapter 1: Web APIs 7

at https://www.python.org and click on the link for the “About” page you’ll be redirected to
https://www.python.org/about/. The /about/ piece is the path.

In summary, every URL like https://python.org/about/ has three potential parts:

• a scheme - https
• a hostname - www.python.org
• and an (optional) path - /about/

Internet Protocol Suite

Once we know the actual URL of a resource, a whole collection of other technologies must work
properly (together) to connect the client with the server and load an actual webpage. This is
broadly referred to as the internet protocol suite14 and there are entire books written on just
this topic. For our purposes, however, we can stick to the broad basics.

Several things happen when a user types https://www.google.com into their web browser and
hits Enter. First the browser needs to find the desired server, somewhere, on the vast internet.
It uses a domain name service (DNS) to translate the domain name “google.com” into an IP
address15 , which is a unique sequence of numbers representing every connected device on the
internet. Domain names are used because it is easier for humans to remember a domain name
like “google.com” than an IP address like “172.217.164.68”.

After the browser has the IP address for a given domain, it needs a way to set up a consistent
connection with the desired server. This happens via the Transmission Control Protocol (TCP)
which provides reliable, ordered, and error-checked delivery of bytes between two application.

To establish a TCP connection between two computers, a three-way “handshake” occurs


between the client and server:

1. The client sends a SYN asking to establish a connection


2. The server responds with a SYN-ACK acknowledging the request and passing a connection
parameter
14
https://en.wikipedia.org/wiki/Internet_protocol_suite
15
https://en.wikipedia.org/wiki/IP_address
Chapter 1: Web APIs 8

3. The client sends an ACK back to the server confirming the connection

Once the TCP connection is established, the two computers can start communicating via HTTP.

HTTP Verbs

Every webpage contains both an address (the URL) as well as a list of approved actions known as
HTTP verbs. So far we’ve mainly talked about getting a web page, but it’s also possible to create,
edit, and delete content.

Consider the Facebook website. After logging in, you can read your timeline, create a new
post, or edit/delete an existing one. These four actions Create-Read-Update-Delete are known
colloquially as CRUD functionality and represent the overwhelming majority of actions taken
online.

The HTTP protocol contains a number of request methods16 that can be used while requesting
information from a server. The four most common map to CRUD functionality. They are POST,
GET, PUT, and DELETE.

Diagram

CRUD HTTP Verbs


---- ----------
Create <--------------------> POST
Read <--------------------> GET
Update <--------------------> PUT
Delete <--------------------> DELETE

To create content you use POST, to read content GET, to update it PUT, and to delete it you use
DELETE.

Endpoints

A website consists of web pages with HTML, CSS, images, JavaScript, and more. But a web API
has endpoints instead which are URLs with a list of available actions (HTTP verbs) that expose
16
https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_method
Chapter 1: Web APIs 9

data (typically in JSON17 , which is the most common data format these days and the default for
Django REST Framework).

For example, we could create the following API endpoints for a new website called mysite.

Diagram

https://www.mysite.com/api/users # GET returns all users


https://www.mysite.com/api/users/<id> # GET returns a single user

In the first endpoint, /api/users, an available GET request returns a list of all available users. This
type of endpoint which returns multiple data resources is known as a collection.

The second endpoint /api/users/<id> represents a single user. A GET request returns informa-
tion about just that one user.

If we added POST to the first endpoint we could create a new user, while adding DELETE to the
second endpoint would allow us to delete a single user.

We will become much more familiar with API endpoints over the course of this book but
ultimately creating an API involves making a series of endpoints: URLs with associated HTTP
verbs.

A webpage consists of HTML, CSS, images, and more. But an endpoint is just a way to access data
via the available HTTP verbs.

HTTP

We’ve already talked a lot about HTTP in this chapter, but here we will describe what it actually
is and how it works.

HTTP is a request-response protocol between two computers that have an existing TCP connec-
tion. The computer making the requests is known as the client while the computer responding
is known as the server. Typically a client is a web browser but it could also be an iOS app or really
any internet-connected device. A server is a fancy name for any computer optimized to work
17
https://json.org/
Chapter 1: Web APIs 10

over the internet. All we really need to transform a basic laptop into a server is some special
software and a persistent internet connection.

Every HTTP message consists of a status line, headers, and optional body data. For example, here
is a sample HTTP message that a browser might send to request the Google homepage located
at https://www.google.com.

Diagram

GET / HTTP/1.1
Host: google.com
Accept_Language: en-US

The top line is known as the request line and it specifies the HTTP method to use (GET), the path
(/), and the specific version of HTTP to use (HTTP/1.1).

The two subsequent lines are HTTP headers: Host is the domain name and Accept_Language is
the language to use, in this case American English. There are many HTTP headers18 available.

HTTP messages also have an optional third section, known as the body. However we only see a
body message with HTTP responses containing data.

For simplicity, let’s assume that the Google homepage only contained the HTML “Hello, World!”
This is what the HTTP response message from a Google server might look like.

Diagram

HTTP/1.1 200 OK
Date: Mon, 03 Aug 2020 23:26:07 GMT
Server: gws
Accept-Ranges: bytes
Content-Length: 13
Content-Type: text/html; charset=UTF-8

Hello, world!

The top line is the response line and it specifies that we are using HTTP/1.1. The status code 200
OK indicates the request by the client was successful (more on status codes shortly).
18
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
Chapter 1: Web APIs 11

The next eight lines are HTTP headers. And finally after a line break there is our actual body
content of “Hello, world!”.

Every HTTP message, whether a request or response, therefore has the following format:

Diagram

Response/request line
Headers...

(optional) Body

Most web pages contain multiple resources that require multiple HTTP request/response cycles.
If a webpage had HTML, one CSS file, and an image, three separate trips back-and-forth between
the client and server would be required before the complete web page could be rendered in the
browser.

Status Codes

Once your web browser has executed an HTTP Request on a URL there is no guarantee things will
actually work! Thus there is a quite lengthy list of HTTP Status Codes19 available to accompany
each HTTP response.

You can tell the general type of status code based on the following system:

• 2xx Success - the action requested by the client was received, understood, and accepted
• 3xx Redirection - the requested URL has moved
• 4xx Client Error - there was an error, typically a bad URL request by the client
• 5xx Server Error - the server failed to resolve a request

There is no need to memorize all the available status codes. With practice you will become
familiar with the most common ones such as 200 (OK), 201 (Created), 301 (Moved Permanently),
404 (Not Found), and 500 (Server Error).
19
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
Chapter 1: Web APIs 12

The important thing to remember is that, generally speaking, there are only four potential
outcomes to any given HTTP request: it worked (2xx), it was redirected somehow (3xx), the client
made an error (4xx), or the server made an error (5xx).

These status codes are automatically placed in the request/response line at the top of every
HTTP message.

Statelessness

A final important point to make about HTTP is that it is a stateless protocol. This means
each request/response pair is completely independent of the previous one. There is no stored
memory of past interactions, which is known as state20 in computer science.

Statelessness brings a lot of benefits to HTTP. Since all electronic communication systems have
signal loss over time, if we did not have a stateless protocol, things would constantly break if
one request/response cycle didn’t go through. As a result HTTP is known as a very resilient
distributed protocol.

The downside however is that managing state is really, really important in web applications. State
is how a website remembers that you’ve logged in and how an e-commerce site manages your
shopping cart. It’s fundamental to how we use modern websites, yet it’s not supported on HTTP
itself.

Historically state was maintained on the server but it has moved more and more to the client,
the web browser, in modern front-end frameworks like React, Angular, and Vue. We’ll learn more
about state when we cover user authentication but remember that HTTP is stateless. This makes
it very good for reliably sending information between two computers, but bad at remembering
anything outside of each individual request/response pair.

REST

REpresentational State Transfer (REST)21 is an architecture first proposed in 2000 by Roy Fielding
20
https://en.wikipedia.org/wiki/State_(computer_science)
21
https://en.wikipedia.org/wiki/Representational_state_transfer
Chapter 1: Web APIs 13

in his dissertation thesis. It is an approach to building APIs on top of the web, which means on
top of the HTTP protocol.

Entire books have been written on what makes an API actually RESTful or not. But there are three
main traits that we will focus on here for our purposes. Every RESTful API:

• is stateless, like HTTP


• supports common HTTP verbs (GET, POST, PUT, DELETE, etc.)
• returns data in either the JSON or XML format

Any RESTful API must, at a minimum, have these three principles. The standard is important
because it provides a consistent way to both design and consume web APIs.

Conclusion

While there is a lot of technology underlying the modern world wide web, we as developers
don’t have to implement it all from scratch. The beautiful combination of Django and Django
REST Framework handles, properly, most of the complexity involved with web APIs. However it
is important to have at least a broad understanding of how all the pieces fit together.

Ultimately a web API is a collection of endpoints that expose certain parts of an underlying
database. As developers we control the URLs for each endpoint, what underlying data is available,
and what actions are possible via HTTP verbs. By using HTTP headers we can set various levels
of authentication and permission too as we will see later in the book.
Random documents with unrelated
content Scribd suggests to you:
shore; and because in point of fact such dominion, unless in the
neighbourhood of forts, is actually maintained by other means, as by
coastguards and naval vessels. Nevertheless the principle, though
resting largely on hypothesis, had much to recommend it, and it
gradually became incorporated into international law as the rule for
fixing the boundary of the territorial waters. Apart from its intrinsic
merits, its acceptance was perhaps not a little facilitated by the
felicity with which it was expressed. Bynkershoek gave it the form
almost of an aphorism, and the phrase, terræ dominium finitur ubi
finitur armorum vis, has been quoted by almost all later writers.

But although the doctrine of Bynkershoek was attractive, and was


eventually accepted almost everywhere, it did not command
immediate assent. The publicists who came after Bynkershoek in the
eighteenth century, while usually referring to the cannon-range limit,
or adopting it with respect to questions of prize, did not as a rule
adhere to it as the sole principle for delimiting the territorial belt.
The earliest notice of it after the Quæstiones appeared seems to
have been by Casaregi, an Italian writer of authority, who was judge
in the Court of the Grand Duke of Tuscany, in a work which
appeared in 1740, and referred more especially to the practice in the
Mediterranean.1016 Foreign ships, he said, were under the protection
of the prince whose seas they sail through, when they are in his
ports, or in the sea so near as to be within the range of guns on
shore; if seized by the enemy there, they require to be restored.1017
This was the ordinary rule in regard to neutrality; but with regard to
the question of sovereignty in the neighbouring sea, Casaregi
followed preceding Italian jurists in assigning a space of one
hundred miles from the coast for civil and criminal jurisdiction, with
the power of levying tolls and dues from passing ships, and even of
prohibiting or permitting navigation.

A little later a Spanish writer, Abreu y Bertodano, in a work on the


law of maritime prize,1018 held that it was unlawful for cruisers to
attack the enemy’s vessels in the seas adjacent to the coast of a
neutral within a distance of two leagues from the shore, or within
the reach of a cannon-shot from it. He stated that no European
Power had asserted the dominion of the sea with more heat and
boldness than Great Britain, and yet by Act of Parliament the
visitation of ships by the coastguard was restricted to two leagues
from the coast, which was as much as could reasonably be
claimed.1019 But this author also followed the Italian rule that
jurisdiction, including the levying of tolls, &c., was not limited to the
coast waters, but extended for at least a hundred miles from the
shore, and said that this was in agreement with the teaching of the
lawyers of all nations.1020

Wolff, who wrote on the law of nations about the same time,
appears rather to have followed the opinions of Puffendorf. He
argued that the use of the sea next the shore, for fishing and the
collection of things that grow on it, was not inexhaustible, nor its use
for navigation always innocuous; and since it served as a protection
for the adjoining state, it was reasonable that it should be under the
dominion of that state. The inhabitants of the shores had therefore
the right to occupy it “so far as they can maintain their dominion
over it”; and the same was true of straits and bays.1021

Some ten years later Vattel, the pupil and follower of Wolff,
published a work on the law of nations, which is still of authority,
and in which much the same opinions as those of Puffendorf and
Wolff are expressed.1022 On the general question of the appropriation
of the sea the usual statement was made; but Vattel held that a
nation might acquire exclusive rights of navigation and fishery in the
open sea by treaties, but not by prescription, unless in virtue of the
consent or tacit agreement of other nations. Thus “when a nation
that is in possession of the navigation and fishery in certain tracts of
the sea claims an exclusive right of them, and forbids all
participation on the part of other nations, if the others obey that
prohibition with sufficient marks of acquiescence, they tacitly
renounce their own right in favour of that nation, and establish for
her a new right, which she may afterwards lawfully maintain against
them, especially when it is confirmed by long use.” On the other
hand, Vattel states that the uses of the sea near the coast render it
very susceptible of appropriation: it supplies fish, shells, pearls, and
other things, and with respect to all these its use is not
inexhaustible. A maritime people may therefore appropriate and
convert to their own profit “an advantage which nature has placed
within their reach as to enable them conveniently to take possession
of it, in the same manner as they possessed themselves of the
dominion of the land they inhabit.” Vattel does not state his opinion
as to the distance from the coast within which the fisheries may be
appropriated, but from the examples he cites it is evident that the
space might extend considerably beyond the range of guns. “Who
can doubt,” he asks, “that the pearl fisheries of Bahrem and Ceylon
may lawfully become property?” And the same principle may be
applied to floating fish, which appear less liable to be exhausted. If a
people, he says, have on their coast a particular and profitable
fishery of which they can become masters, shall they not be
permitted to appropriate that bounteous gift of nature as an
appendage to the country they possess, and to reserve to
themselves the great advantages which their commerce may thence
derive, if there is sufficient abundance of fish to furnish neighbouring
nations? Thus, Vattel states, the herring fishery on the British coasts
might have been appropriated by the English if they had originally
taken exclusive possession of it, instead of allowing other nations to
take part in it. Another reason for the extension of territorial
dominion over the adjoining sea, “as far as a nation is able to
protect its right,” is the security and welfare of the state; but the
author says it is not easy to fix upon any precise distance. Between
nation and nation, “all that can reasonably be said is that, in general,
the dominion of the state over the neighbouring sea extends as far
as her safety renders it necessary and her power is able to assert it.”
At the time he wrote, “the whole extent of the sea which is within
cannon-shot of the coast is considered as forming part of the
territory; and for that reason a vessel taken under the cannon of a
neutral fortress is not a lawful prize.” The principle that applied to
the adjacent sea applied with much greater force to roads, bays, and
straits, since they were more capable of being possessed, and were
of greater importance to the safety of the country. But such areas
must be “of small extent,” and not great tracts of sea—as Hudson’s
Bay and the Straits of Magellan: a bay “whose entrance can be
defended” might clearly be appropriated.

The opinions of Vattel do not, therefore, materially differ from those


of Puffendorf in the previous century, though the tendency of the
earlier writer to allow a wide dominion is modified. Bynkershoek’s
principle of cannon range is adopted in a somewhat cautious
manner, and shown to apply especially to captures under the guns of
a neutral fortress. But the general argument in regard to fisheries,
the security of the state, and the exercise of territorial jurisdiction—
as in the King’s Chambers on the English coast, which Vattel cites as
an example of the practice—implies that a nation might lawfully
extend its sovereignty much beyond the range of guns.

In the writings of other international jurists later in the century, the


tendency to narrow the extent of the territorial sea in accordance
with Bynkershoek’s teaching becomes more manifest, particularly in
those which treat specially of the rights of neutrals. Hübner, who
was assessor in the Consistorial Court at Copenhagen, treating of
this subject, said with reference to Bynkershoek’s doctrine that it
was evident the parts of the adjacent sea belonged to the master of
the country, as accessory to the land,—first, “because it is in his
power to take possession and to maintain it by means of forts and
batteries which he is able to erect on the shore”; and, secondly,
because the waters serve as a rampart to the land.1023

Valin, a French writer of authority, introduced another principle in


combination with that of the range of guns. In his commentary on
the marine ordinance of Louis XIV., first published in 1760, he stated
that the rule that the adjacent sea within the reach of guns from the
coast is under the dominion of the neighbouring state was
universally recognised, the alternative distance which he gave being
two leagues—the same as given by Abreu. But he thought that the
depth of the water ought also to be taken into account, and that the
sea up to the point at which the bottom ceased to be reached by a
sounding-line pertained to the adjoining coast—an idea vague and
impracticable.1024

In 1778, Moser, a councillor of state in Denmark, adopted


Bynkershoek’s doctrine, declaring that the sea adjacent to the coast
of a country was, according to the law of nations, indisputably under
the sovereignty of the neighbouring territory, as far as a cannon-ball
could reach.1025 On the other hand, Lampredi, Professor of Public
Law in the University of Pisa, writing at the same time, while
allowing to a state the right of property in the adjacent sea, makes
the limit of its dominion depend, not on cannon range, but upon
considerations of general convenience.1026 Another contemporary
Italian, Galiani, who was Sicilian Secretary of Legation at Paris, and
was employed by his master, the King of the Two Sicilies, to write a
book in defence of his adhesion to the Russian League of Armed
Neutrality, expressed somewhat varying opinions as to the limits of
the territorial sea.1027 Admitting as a received doctrine that the belt
of sea washing the coasts of a country belonged to it as a part of its
territory, he at first seems to extend it, in accordance with the Italian
principles, as far as the authorities can cause their jurisdiction to be
enforced. Later, he advances the gunshot limit for certain purposes,
as the imposition of tolls and the regulation of navigation; and
finally, with regard to the observance of neutrality he considers the
boundary should be two leagues, or twice the distance of cannon
range, and he appears to have been the first to fix upon three miles
as equivalent to the range of guns.1028

G. F. von Martens, one of the greatest authorities on international


law, writing a little later, more definitely adopted the principle of the
range of guns; but he gave the equivalent distance as “three
leagues,” and moreover admitted that a nation might acquire
maritime dominion beyond that limit.1029 The principle of
appropriation, he says, which applies to lakes and rivers also applies
to straits, which are in general not wider than great rivers and lakes,
so that the middle may be reached by a cannon-ball fired from the
shore; and those parts of the sea which border the land may also be
regarded as the property and under the dominion of the nation
possessing the coast. By a custom generally acknowledged, he
continues, the authority of the possessor of the coast extends as far
as the range of guns from the shore—that is to say, to a distance of
three leagues;1030 and he adds that this distance is the least that a
nation ought to claim as the extent of its dominion in the sea. But he
also says that a nation may occupy and extend its dominion beyond
that distance, and maintain it, if the security of the nation require it,
by a fleet of armed vessels; and, further, that its sovereignty may
extend as far as it has been acknowledged to reach by the consent
of other nations, and beyond the boundary of its property—Von
Martens, like many others, drawing a distinction between property in
the sea and sovereignty over it. As examples of such cases, he
definitely states, as well established at the time he wrote, that St
George’s Channel was under the sovereignty of Great Britain and the
Gulf of Bothnia under that of Sweden, while the straits between
Sweden and Denmark were considered to be the property of
Denmark. On the other hand, the Bay of Biscay, the Mediterranean,
the Straits of Gibraltar, the White Sea, and the North Sea were
acknowledged to be free.

Towards the close of the century, an Italian author, Azuni, who was
judge in the commercial court at Nice, published a work on maritime
law, in which he dealt with the territorial sea; and adopting the
range of guns as the principle of delimitation, he declared that the
equivalent distance ought to be fixed at three miles, which, he said,
was “without doubt” the farthest a cannon-shot could ever be made
to reach.1031 In this Azuni followed Galiani, making the statement
more definite, and thus we see the three-mile limit put forward by
publicists, as the alternative to the range of guns, before the century
closed. In point of fact, however, it had actually been applied in the
United States a year or two before Azuni wrote;1032 and it is clear
from what he says that no general agreement then existed as to the
extent of the territorial sea, for he complained that the limit was still
undecided,—a statement repeated in his enlarged work, published in
1805,—and he contended that it ought to be fixed by a solemn
treaty between the maritime Powers, as Meadows had suggested a
century before.1033 Although Azuni adopted the principle of cannon
range, and, like Galiani, declared that three miles was the farthest
that a ball or bomb could be thrown,1034 he was of opinion that for
purposes of neutrality, as an asylum against hostilities, the territorial
waters should be extended to two leagues from either shore in the
case of bays and gulfs, which, he says, even when their centre was
at a greater distance than three miles from either shore, were
admitted to be territorial. He even strongly recommended the
adoption of the range of vision as the boundary of neutral waters in
time of war.

From the above review of the opinions of publicists in the latter half
of the eighteenth century, it is evident that there was a general
agreement that the sea, at least as far as the range of guns from the
coast, was accessory to the land: no one doubted that this space at
all events was included within the territorial sea of the neighbouring
country. Almost all the writers went further, and held that the
sovereignty of a state was not confined to gunshot range, but could
be extended to a greater distance from the coast, either for the
security of the state or for jurisdiction, but there was not agreement
as to how far this could be carried. We see, moreover, the growing
tendency to assign a fixed distance as an alternative to cannon
range or as a boundary to neutral waters. Abreu, Valin, and Galiani
placed it at two leagues from the coast, and the same distance is
given by the writer of the article “Mer” in a great French work
published in 17771035—that is, twice the distance of cannon range,
which was said to be one marine league, or three miles.

Turning from the opinions of international jurists in the eighteenth


century to the practice and usage of nations in the same period, we
may note certain features of prominence: (1) the continued
decadence of claims to sovereignty over extensive areas; (2) the
growing custom of fixing definite boundaries for special purposes by
international treaties or by municipal laws; (3) legal decisions by
which the limit of cannon range was recognised in certain cases. In
the eighteenth century claims to the sovereignty of seas became
greatly restricted and lost their previous importance. The feebleness
of Venice prevented her from asserting in practice the rights which
were hers by law and ancient prescription. Both Vattel and Azuni,
while admitting that she possessed a limited sovereignty, questioned
whether any other Power would recognise her claim to the whole of
the Adriatic. “Such pretensions to empire,” says the former author,
“are respected so long as the nation that makes them is able to
assert them by force, but they vanish, of course, on the decline of
her power.” In 1779, indeed, before Azuni wrote, the Republic issued
a decree respecting her neutrality, in which the limit of cannon range
was fixed as the boundary of her waters for that purpose.1036 Her
ancient dominion over the Adriatic was soon finally extinguished.
When Napoleon conquered Venice in 1795 and transferred her like a
chattel to Austria, her maritime sovereignty came to an end, and the
picturesque and symbolic ceremony of “espousing” the Adriatic,
which had been performed by the Doge every year for many
centuries, terminated with it.1037

The similar pretension of England to sovereignty of the sea, as


previously mentioned, did not survive till this century, except on the
point of the flag; and this ceremony fell into desuetude, and was
abandoned finally in 1805. Great Britain now appeared rather as a
champion of the freedom of the sea than as an advocate of mare
clausum. This was particularly shown in connection with the rights
claimed by Denmark in the northern sea, especially at Iceland and
the Danish portion of Greenland. As already stated, Denmark tried in
the preceding century to keep alive her ancient rights to the fisheries
and trade in these remote regions, and having failed in her efforts,
introduced a fixed limit of forty geographical miles from the coast,
within which whale-fishing by foreigners was forbidden (see p. 529).

While Denmark was unsuccessfully endeavouring to assert exclusive


rights to the fisheries within a wide extent of water in the northern
seas, she was at the same time claiming a much less extensive
space along her coasts for purposes of neutrality. Moreover, it may
be added that just as in most European countries the cannon-range
limit and then the three-mile belt—which likewise originated in
connection with neutral rights—came to be applied as the boundary
of the territorial seas for all purposes, so the Danish limit for neutral
waters, which was a different one, was also adopted later as the
general boundary of the territorial seas by the Scandinavian states.
The decree in regard to neutrality was issued in 1745 by the King of
Denmark and Norway, and communicated to the foreign consuls,
and it forbade all foreign privateers to capture any vessel of the
enemy within a distance of one league, of fifteen to a degree of
latitude, from the coast or its outlying banks or rocks.1038 This
ordinance in regard to neutral waters was renewed in 1756, 1759,
and 1779,—that of 1759 expressly declaring that the league was the
marine league of fifteen to a degree.1039 It may be added here that
early in the next century, in view of the war with Great Britain,
decrees were published prohibiting either Danish or Norwegian
privateers from capturing the enemy’s vessels within the territorial
sea of any foreign state which was friendly or neutral; and such sea,
it was said, was usually supposed to extend for one marine league
from the coast.1040 The same distance of four geographical miles was
assigned by Sweden, in a decree of 12th April 1808, which
prohibited the seizure of vessels nearer the coast of neutrals than
the limit named.1041

The various ordinances cited referred solely to the limit of the


territorial sea in relation to neutrality. But as early as 1747 the same
boundary was applied to a limited part of the Norwegian coast in
connection with fisheries. In that year a royal decree prohibited
Russian fishermen at Finmarken from fishing within one league of
the land,—a measure which was not opposed by the Russian
Government, and which was renewed by a Norwegian law in
1830.1042 In 1812, as we shall see (p. 653), the territorial waters of
Denmark and Norway were declared to extend to four miles from the
coast or its outlying isles,—that is to say, the limit which was
adopted for neutrality was applied in regard to fisheries and other
purposes.

Another example of the decadence of wide claims to maritime


sovereignty is to be found in the case of Spain, which, like the
Scandinavian countries, adopted a fixed limit in the eighteenth
century as the boundary of her territorial waters, and, as with them
also, it was placed at a greater distance than the range of guns from
the coast. An eminent Spanish publicist, Abreu, as we have seen,
declared in 1746 that the boundary of neutral waters should be at
least two leagues from the coast, and by a royal decree of 17th
December 1760 this distance was assigned, the territorial sea of
Spain being declared to extend to six miles from the land. This
boundary was again given in 1775 and in 1830, and it is still retained
by Spain—and also, until last year, by Portugal—as the maritime
frontier for customs, fishery, neutrality, and jurisdiction.1043 At various
times Spain has entered into treaties with her neighbours, France
and Portugal, concerning the rights of fishery within the six-mile
zone, either for reciprocal liberty to fish in the whole extent of the
territorial sea, or in the outer belt of three miles. A treaty of this kind
was concluded with France in 1768.1044

The uprising in America in 1775, which resulted in the independence


of the United States, brought in its train a widespread maritime war,
Great Britain having to meet the naval forces of France, Holland, and
Spain, and at this time and throughout the remainder of the century
we meet with numerous decrees and treaties bearing upon the
delimitation of territorial waters, particularly in connection with the
rights of neutrals. One of the first of these was a circular which the
American Commissioners at the Court of Paris addressed to the
commanders of American armed vessels in 1777, instructing them to
abstain from capturing the enemy’s vessels, or vessels of neutrals,
when they were “under the protection of a port, river, or coast of a
neutral country.” To do so, it was said, would be contrary to the
usage and customs of nations; and the proclamation issued by the
American Government in the following year on the same subject is
couched in equally general terms.1045

We find the same want of definition in an edict of the King of the


Two Sicilies in the same year, which speaks only of the accustomed
rules being observed in his “ports, coasts, and adjacent seas.”1046 But
in corresponding proclamations issued at the same time by the
Grand Duke of Tuscany, the Republic of Genoa, the Republic of
Venice, and the Pope, the range of guns is expressly mentioned as
determining the boundary of their territorial waters in respect to
neutrality. The Grand Duke prohibited all acts of hostility in the ports
or coasts of Leghorn, within certain places specified, and in the seas
adjacent to all his other ports, castles, or coasts within gunshot of
the shore.1047 With respect to Civita Vecchia, Ancona, and his other
territories, the Pope prohibited, “according to the common usage of
nations,” all acts of hostility or superiority between belligerents there
or in the adjacent seas, “or generally within the range of guns from
the shore”;1048 while the Genoese edict forbade all acts of hostility
between belligerents “in the ports, gulfs, and coasts, within range of
guns,”1049 and contained particular rules for carrying the prohibition
into effect. Thus, if such an act of hostility should be committed
within range of cannon, a shot was first to be fired into the air, or to
a distance from the vessel or vessels violating the neutrality, unless
there was risk of damage to other vessels, in which case a blank
shot was to be fired. If this did not put a stop to the transgression,
the offenders were to be assailed with shot and musketry. In places
where cannon were not available, the same course was to be
followed with muskets, and, it was said, the rules had to be carried
out precisely as they had been ordained in a decree of 1756, when,
no doubt, the gunshot limit was equally in force. The Venetian
decree is couched in similar terms, and the size of the cannon whose
range was to determine the limit is mentioned. All acts of force or
authority between belligerents were prohibited “in the ports, roads,
and coasts of our dominion, and in all the adjacent sea, at least to
the distance within range of a large cannon of battery.”1050 In several
of the edicts, as in the two last referred to, the range of vision was
also used as a limit within which no belligerent vessel was to be
allowed to station itself, or cruise about waiting for the enemy’s
vessels: such action was prohibited within view of the ports or roads.

It will be noticed that all these edicts regarding neutral waters in


which the limit of cannon range was prescribed, emanated from the
small Mediterranean states; but in many of the international treaties
which followed the Armed Neutrality of 1780 the gunshot limit for
neutral waters was also adopted. This league, which was directed
against Great Britain, had its source in a declaration by the Empress
Catherine II. of Russia regarding the rights of neutrals; especially
that neutral vessels should be free to carry on trade on the coasts of
belligerents, and that the property of belligerents in neutral vessels,
except arms, equipment, and munitions of war, should be free from
capture. The seizure of enemy’s goods in neutral ships by English
cruisers bore hardly on the commerce of neutral countries; and for
this reason, and, according to English views, because it was
perceived by the other Powers that they could not directly contend
against the naval force of Great Britain, a new code of international
law was introduced which would have the effect of sapping it.1051 In
some of the treaties referred to, the limits of neutral waters were
defined in vague or general terms, as in that of 1782 between the
United States and the United Provinces.1052 The gunshot limit,
however, was specified in a treaty between the United States and
Morocco in 1785, which stipulated that if a vessel of either state was
engaged with that of another Christian Power within the range of
guns of a castle of the other state, it was to be protected and
defended;1053 in a treaty of navigation and commerce between Great
Britain and France in 1786;1054 and in a treaty between France and
Russia in 1787. In the latter it was stipulated that in agreement with
the principles laid down in the Russian declaration regarding the
navigation of neutrals, either Power, if at war, should abstain from
attacking the enemy’s vessels within cannon range of the coasts of
the other Power, or in the ports, harbours, gulfs, and “other waters
comprised under the name of closed waters.”1055 Russian activity in
the direction indicated was shown by the conclusion of a similar
treaty in the same terms with the Two Sicilies a few days later.1056 A
little later, in 1803, the range of guns was adopted by Austria as
determining the extent of neutral waters, as in the treaties above
referred to.1057

In contrast to the gunshot limit in connection with neutrality, was


another which Spain incorporated in a treaty with Tripoli in 1784, by
which it was agreed that Tripolitan vessels of war or privateers
should not capture ships of their enemy within ten leagues of the
coasts of the Spanish dominions1058—that is to say, within the same
extent of sea as was expressed in the treaty between France and
Algeria a century earlier.1059 A few years later the same limit of ten
leagues was agreed to in a treaty between Great Britain and Spain
concerning fisheries and navigation in certain parts of the Pacific.
Disputes had arisen with Spain concerning proceedings at Nootka
Sound, Vancouver; and in a convention between the two Powers,
signed in 1790, it was agreed, inter alia, that British subjects should
not navigate or carry on their fishery within a distance of ten sea
leagues from any part of the coast already occupied by Spain, the
object being to prevent illegal trading with the Spanish
settlements.1060

We thus perceive that towards the end of the eighteenth century


various maritime boundaries were assigned in particular places for
particular purposes, and that many states looked upon the limit of
gunshot from an open coast as fixing the extent of their neutral
waters. But hitherto, with the exception of the league limit
prescribed by Denmark and Norway, which had no avowed reference
to the range of guns, and was in reality equivalent to much more
than three miles, no Power had yet adopted one marine league as
the equivalent of gunshot from the shore. It appears that this step
was first taken by the United States of America, and it is of interest
to note that the three-mile limit was put forward tentatively, and, in
a manner, as a temporary expedient. When the war between Great
Britain and France broke out in 1793, the United States found it
necessary to define the extent of the line of territorial protection
which they claimed on their coast, in order to give effect to their
neutral rights and duties. Washington, who was then President,
instructed the executive officers to consider the line restrained, for
the time being, to the distance of one sea league, or three
geographical miles, from the shores, a distance which was said to be
not more extensive than was claimed by any other Power. This limit
was adopted tentatively, since the Government “did not propose, at
that time, and without amicable communication with the foreign
Powers interested in the navigation of the coast, to fix on the
distance to which they might ultimately insist on the right of
protection.” It was stated that the greatest distance to which any
“respectable assent” among nations had ever been given was the
range of vision, which was estimated at upwards of twenty miles,
and the smallest distance claimed by any nation was “the utmost
range of a cannon-ball, usually stated at one sea league.”1061 Besides
the extent of sea referred to, the bays and rivers were held by usage
and the law of nations to be territorial, with immunity from
belligerent operations. This was well shown in the same year, when
the United States claimed that the whole of Delaware Bay and New
Jersey, an arm of the sea about fifty English miles in length and a
little over eleven miles wide at the entrance, was under their
territorial jurisdiction, and ordered the restitution of a British vessel,
the Grange, which had been captured there by a French frigate,
L’Ambuscade; and this was done notwithstanding the protest of the
French Minister that Delaware Bay was open sea and not under the
exclusive jurisdiction of the United States. The American
Government rested its action on the law of nations, and declared
that they were entitled to attach to their coasts an extent of sea
beyond the reach of cannon-shot—a claim which showed that the
three-mile limit had not been adopted as an inflexible rule.1062

Next year the United States Congress passed a law authorising the
district courts to take cognisance of all captures made within one
marine league of the American shores;1063 but in the treaty
concluded between Great Britain and the United States in the same
year, it is interesting to observe that the less precise limit of gunshot
was adopted, in the same words as in the treaty of 1786 between
Great Britain and France. The twenty-fifth article of this treaty
provided that neither Government should permit the ships or goods
belonging to the citizens or subjects of the other “to be taken within
cannon-shot of the coast, nor in any of the bays, ports, or rivers of
their territories, by ships of war, or others, having commissions from
any prince, republic, or state whatever.”1064

It may be mentioned here that the claims which have been put
forward by the United States as to the extent of their territorial or
jurisdictional waters have varied greatly on different occasions. The
above declaration to M. Genet was, for instance, repudiated by
President Jefferson as establishing a fixed limit; and it was claimed
that the limit of neutrality should extend “to the Gulf Stream, which
was a natural boundary (!), and within which we ought not to suffer
any hostility to be committed.”1065 On another occasion, in a
controversy about the right of jurisdiction, they claimed that the
extent of neutral immunity off the American coast ought at least to
correspond with the claims maintained by Great Britain around her
own territory, and that no belligerent rights should be exercised
within “the chambers formed by headlands, or anywhere at sea
within the distance of four leagues, or from a right line from one
headland to another.”1066 The American Government endeavoured to
obtain from England in the same year the recognition of a territorial
belt six miles in breadth, and in the draft treaty proposed in 1807 a
distance of five miles was in reality specified.1067
CHAPTER II.
GENERAL ADOPTION OF THE THREE-MILE LIMIT.

It is evident from the foregoing that, notwithstanding the variation in


the extent of water claimed in certain cases, the principle of
determining the general boundary of the territorial sea by the range
of guns from the coast had become tolerably firmly established in
the practice of nations before the end of the eighteenth century,
with reference in particular to the rights of neutrals. Shortly before
the century closed, moreover, we have seen that one of the
important maritime Powers, the United States of America, had
adopted a fixed distance of three miles or one marine league as
equivalent to the utmost range of the cannon of those days. The
range of guns naturally varied according to their size and power, and
though it was specified in some of the Continental ordinances that
the distance was to be determined by a large gun of battery, there
was no certainty that it would be everywhere the same. It was thus
clearly an advantage to have a fixed distance, which could be
marked on charts, substituted for the less definite cannon range, so
long as it really represented it. By the progress of the military art,
however, most notably perhaps after about the middle of last
century, the range of guns became enormously increased, so that
long ago the three-mile limit ceased to represent it.

The new boundary of one marine league, as equivalent to the range


of guns, was soon introduced into English law and practice, in the
first place through the decisions of the High Court of Admiralty in
questions affecting the extent of neutral waters. It is noteworthy
that nothing was heard at this period about the principle of the
King’s Chambers in such cases. It is very doubtful whether, as the
American Government implied in 1806, the boundaries of the King’s
Chambers had retained their validity at the beginning of last century.
There seems to be no evidence that they were enforced during the
eighteenth century, or even in the closing years of the seventeenth,
possibly because occasions to test the point had become rare. But it
is perhaps more probable that the claim to the King’s Chambers was
allowed gradually to die out, and that the deliberate omission of any
reference to them in the later proclamations of Charles II. (see p.
554) foreshadowed this change in practice. It is clear at all events
that long before the end of the eighteenth century it was well
established that a vessel captured by one belligerent from another
belligerent in a port of a neutral state or within the actual reach of
cannon was not good prize.1068 The next step was to give effect to
the same principle, whether the place was actually within the range
of a fort or not.

The decisions which introduced the three-mile limit into English


jurisprudence were those of Sir William Scott (afterwards Lord
Stowell) at the beginning of last century. In 1800 and 1801 this
great authority adopted both the gunshot limit and the distance of
three miles as its equivalent for the boundary of neutral waters, in
deciding the well-known cases of the Twee Gebroeders. It was these
decisions of Lord Stowell’s which introduced the three-mile limit into
English jurisprudence. The cases arose from the capture of certain
vessels in 1799, by the boats of a British man-of-war, in the
Groningen-Watt, between East Friesland and the island of Borkum,
in the belief that they were bound from Hamburg to Amsterdam,
which was then blockaded by the British; and it was claimed by the
King of Prussia that the capture was made within the territory of that
state. In deciding the first case,1069 Lord Stowell found that the
capturing vessel was “lying within the limits to which neutral
immunity is usually conceded. She was lying in the eastern branch of
the Eems, within what may, I think, be considered as a distance of
three miles, at most, from East Friesland. An exact measurement
cannot easily be obtained; but in a case of this nature, in which the
Court would not willingly act with an unfavourable minuteness
towards a neutral state, it will be disposed to calculate the distance
very liberally; and more especially, as the spot in question is a sand
covered with water only on the flow of the tide, but immediately
connected with the land of East Friesland, and when dry, may be
considered as making part of it. I am of opinion, that the ship was
lying within those limits in which all direct hostile operations are by
the law of nations forbidden to be exercised.”1070 In this decision the
three-mile limit is assumed to be, “by the law of nations,” the
boundary of the neutral waters. It is also to be observed that the
distance was reckoned, not from low-water mark, but apparently
from the land; while according to the rule apparently governing such
cases now, the sand-bank itself would be a part of the territory, and
the distance of three miles would be measured from its outer margin
at low water (see fig. 19, p. 635).
Fig. 14.—Facsimile of part of the chart, showing where the “Twee Gebroeders”
were taken. From Robinson, Admiralty Reports.

In deciding the second case, in which the circumstances were much


the same, Lord Stowell said that “in the sea, out of the reach of
cannon shot universal use is presumed”; but he made no reference
to three miles as an equivalent distance.1071 A few years later, in
1805, in deciding the case of the Anna, which was captured at the
mouth of the Mississippi by a British privateer, and in which the
question of the violation of American waters had to be considered,
the same judge, quoting Bynkershoek, said: “We all know that the
rule of law on this subject is terræ dominium finitur, ubi finitur
armorum vis; and since the introduction of fire-arms, that distance
has usually been recognised to be about three miles from shore.”1072

It is, as above stated, in these decisions of the High Court of


Admiralty that the three-mile limit originated in England. They
furnished the legal precedents which regulated subsequent practice.
The gunshot limit was a doctrine borrowed from Continental
publicists, and three miles as its equivalent from recent American
practice. Both were previously unknown to English law.1073

Moreover, although, as we shall see, the writers on international law


had in only a few instances accepted the three-mile limit as an
alternative to the range of guns from the shore, and scarcely any of
the Continental publicists of repute, the actual practice of Great
Britain and the United States, together with the legal decisions in the
British and American courts, and the dicta of the judges, tended
steadily to bring about its adoption. At first the boundary of one
marine league as equivalent to the range of cannon had reference
solely to questions of neutrality, as the capture of prizes, in the
maritime wars that prevailed. But very soon it was applied to other
purposes, and first of all by the British Government in connection
with the rights of fishery. During the peace negotiations with the
United States at Ghent, after the war of 1812-14, the British
Government intimated that they did not intend to grant to the United
States gratuitously the privileges formerly given by the treaty of
1783 “of fishing within the limits of British territory, or of using the
shores of the British territories for purposes connected with the
fisheries.” The treaty of Ghent contained no stipulation on the
subject, but shortly afterwards the British Government expressed its
intention to exclude, and gave instructions to exclude, fishing vessels
of the United States from fishing within the harbours, bays, rivers,
and creeks, and within one marine league of the shores of the
British territories in America, and from drying and curing their fish on
shore. Several American vessels were seized for trespassing within
British waters, and the prolonged diplomatic discussion which
followed resulted in the convention of 1818, by which the fishermen
of the United States were allowed the same rights as British
fishermen on certain parts of the coast, but at all other parts they
were forbidden to fish within a distance of three miles of the “coasts,
bays, creeks, or harbours.”1074 This was the first of the treaties in
which the three-mile limit was specified, and it naturally formed a
precedent for those which followed.

That the principle of adopting the distance in question as the proper


boundary of the territorial sea had not yet become firmly
incorporated in British policy in all cases was, however, shown a few
years later in the negotiations with Russia concerning Behring Sea.
In 1821 the Emperor of Russia issued a ukase or decree, in which he
declared that the pursuit of commerce, whaling, and fishery, and of
all other industry, on all islands, ports, and gulfs, including the whole
of the north-west coast of America, beginning from Behring Straits
to the 51st of northern latitude, and in other parts specified, had
been exclusively granted to Russian subjects; and therefore
prohibiting “all foreign vessels not only to land on the coasts and
islands belonging to Russia, as stated above, but also to approach
them within less than 100 Italian miles,” the penalty for doing so
being the confiscation of the transgressing vessel and the cargo.1075
The Russian Government claimed that the extent of sea of which the
Russian possessions formed the limits “comprehended all the
conditions which are ordinarily attached to closed seas (mers
fermées), and it might consequently judge itself authorised to
exercise upon this sea the right of sovereignty, and especially that of
entirely interdicting the entrance of foreigners; but it preferred only
asserting its essential rights without taking any advantage of
localities.” This, it will be perceived, was a revival in the nineteenth
century of pretensions similar to those which Denmark had advanced
in the seventeenth and eighteenth; and the claim was opposed by
Great Britain and the United States, whose interests were threatened
by it. The British Government declared that it was contrary to the
law of nations, and that it could not admit the right of any Power
possessing the sovereignty of a country to exclude the vessels of
others from the seas on its coasts to a distance of 100 Italian miles.
In its justification Russia cited, not the Italian publicists or the earlier
practice in the Mediterranean, but an article in the treaty of Utrecht,
which assigned thirty leagues as the distance of prohibition (see p.
531),—an argument which was sufficiently answered by the
statement that the distance mentioned was a particular stipulation in
a treaty to which the other party had given its deliberate consent. At
an early period in the discussion the Russian Government suspended
the execution of the ukase, and instructed the commanders of their
ships of war to confine their surveillance as nearly as possible “to
the mainland, i.e., over an extent of sea within the range of cannon-
shot from the shore.”

An article in the draft convention subsequently arranged between


Great Britain and Russia provided for an exclusive fishery, not within
three miles, but within two leagues or six miles, from the coasts of
their respective possessions in the regions referred to; but when the
British Government discovered that in the corresponding convention
concluded a little earlier between Russia and the United States no
limit at all had been specified, they withdrew this article. Mr George
Canning, in a despatch to Mr Stratford Canning, the British
plenipotentiary at St Petersburg, withdrawing the article, said that its
omission was, in truth, immaterial, since “the law of nations assigns
the exclusive sovereignty of one league to each Power on its own
coasts, without any specific stipulation.” The Russian Government
raised no objection to the new article, and the distance from the
coast at which the fishing was to be exercised in common passed
without specification, “and consequently,” added Stratford Canning,
“it rests on the law of nations as generally received.” A little later,
before the convention was ratified, the British plenipotentiary,
thinking it might be desirable to have the law of nations declared
therein, jointly with the Court of Russia, in some ostensible shape,
broached the subject anew and suggested that notes should be
exchanged in London “declaratory of the law as fixing the distance
at one marine league from the shore.” The Russian Minister,
however, expressed disinclination to do anything that might retard
the immediate ratification of the convention; and he assured
Canning that the Russian Government would be content in executing
the convention to abide by the recognised law of nations, and that if
any question should afterwards be raised upon the subject, he would
not refuse to join in making the suggested declaration, “on being
satisfied that the general rule under the law of nations was such as
the English Government supposed.”1076

It is evident from these despatches that the British Government at


that time held the opinion that the territorial waters of a state on an
open coast extended, “by the law of nations,” for one marine league
from the shore. But it would not have been easy for them to adduce
convincing testimony in support of that opinion from the accredited
writers on the law of nations whose works were then available, or
from the general usage of nations apart from Anglo-American
practice. The Russian Government were obviously not satisfied on
the point, and their instruction to their naval commanders to enforce
the limit of cannon range, though that was a less definite boundary,
was more in consonance with the law of nations as generally
understood. It was natural that the British Government should give
weight to the decisions of Lord Stowell in the Admiralty Court.

The Government of the United States, in discussing the Russian


pretension, did not apparently lay the same stress on the principle of
the three-mile limit as they did on some other occasions. The claim
that the Northern Pacific might strictly be regarded as a closed sea
was met by the simple statement that the opposite coasts on the
parallel of 51 degrees were 4000 miles apart. The right of American
subjects to navigate and fish within the prescribed distance of 100
miles from the coast was rested on continuous exercise from the
earliest times. Universal usage, it was declared, which had obtained
the force of law, had established for all coasts “an accessory limit of
a moderate distance” which was sufficient for the security of the
country and for the convenience of its inhabitants, but which laid no
restraint upon the universal right of nations, nor upon the freedom
of commerce and of navigation.1077
In the conventions which followed, it was provided that the subjects
of the contracting Powers should not be molested either in
navigating or in fishing in any part of the Pacific Ocean, and they
were to be at liberty for ten years to frequent without hindrance all
the inland seas, gulfs, havens, and creeks, on the coasts mentioned,
for the purpose of fishing and of trading with the natives, subject to
certain conditions to prevent illicit commerce.1078

It may be here stated that some years later, when American and
British whalers had greatly increased in numbers in Behring Sea, the
Russian officials on several occasions urged their Government to
preserve the sea as a mare clausum,1079 or to prohibit foreign
whalers from approaching the coast within a distance of forty Italian
miles.1080 The Russian Government pointed out in reply that to fix
such a limit would be contrary to the conventions, and might lead to
protests from other Powers, “since no clear and uniform agreement
has yet been arrived at among nations in regard to the limit of
jurisdiction at sea.” In 1847 the Government repeated the
objections, and expressed the opinion that “the limit of a cannon-
shot, that is, about three Italian miles, would alone give rise to no
dispute”; and they further observed that no Power had yet
succeeded in limiting the freedom of fishing in open seas, other
Powers never recognising such pretensions. Subsequently, in 1853,
in consequence of continued complaints as to foreigners fishing in
the sea of Okhotsk, the Russian Government were pressed by the
influential Russian-American Company either to close that great
stretch of waters, as an inland sea, or to prohibit whalers from
approaching close to the shores and whaling in the bays and among
the islands. Instructions were thereupon issued to the commanders
of the Russian cruisers to prevent foreign whalers from entering
bays or gulfs, or from coming “within three Italian miles of the
shores” of Russian America (north of 54° 41´ lat.), the peninsula of
Kamtchatka, Siberia, the Kadjak Archipelago, the Aleutin Islands, the
Pribyloff and Commander Islands, and the others in Behring Sea, as
well as Sakhalin and others; and at the same time it was declared
that while the Sea of Okhotsk, from its geographical position, was a
Russian inland sea, foreigners were to be allowed to take whales
there.1081 Thus the Russian Government adopted at first the principle
of the range of guns, then spoke of this or three Italian miles, and
eventually accepted and enforced, on the great extent of coast
referred to above, the three-mile limit.

Reference must now be made to some decisions in the courts of law


and to certain provisions in particular Acts of Parliament which bear
upon the question of the extent of the territorial waters. Owing to
the long-continued peace on the sea since the decisions of Lord
Stowell at the beginning of last century, few occasions have occurred
for the question of the boundary of neutral waters to be raised. In a
number of civil cases tried in our courts the three-mile limit has,
however, been referred to, either as a ground for the decision, or
more usually as a dictum of the judges, as the proper boundary of
the territorial sea; but this has been frequently coupled with the
qualification that it is the assumed distance of the range of guns, or
the smallest extent that has been claimed by publicists or states.1082
Some of these cases dealt with the vexed question of bays.1083 One
of the most important was tried in 1859, and it referred to the Bristol
Channel. An offence was committed on an American vessel within
one mile of the coast in Penarth Roads, but where the width from
shore to shore is less than ten miles, and Chief Justice Cockburn, in
delivering judgment, said, “We are of opinion that, looking at the
local situation of this sea, it must be taken to belong to the counties
respectively by the shores of which it is bounded; and the fact of the
Holms,1084 between which and the shore of the county of Glamorgan,
the place in question, is situated, having always been treated as part
of the parish of Cardiff, and as part of the county of Glamorgan, is a
strong illustration of the principle on which we proceed, namely, that
the whole of this inland sea, between the counties of Somerset and
Glamorgan, is to be considered as within the counties by the shores
of which its several parts are respectively bounded.” A good deal of
discussion has taken place as to the precise meaning of these words.
It is to be noted that much farther seawards than the place in
question the width of the Channel is less than ten geographical
miles. On the usual rule for bays (as laid down in the fishery
conventions), the ten-mile base-line would pass between Nash Point
in Glamorgan and Hurtstone Point, the headland east of Porlock in
Somerset, and the closing line would be three miles west of this, or
about twenty geographical miles from Penarth Roads. The six-mile
limit, from land to land, is, however, about twenty-seven miles
farther east, between the coast near Goldcliff, in Monmouth, and
that near Walton Castle, Somerset. But about midway between these
two limits (and seawards of Penarth Roads) there is a part where the
three-mile zone around the island, Steepholm, joins that of the coast
on either side, and though eastwards of this there are small areas
beyond the distance of three miles from shore, the fact that the
territorial waters are continuous from side to side at this place
probably confers territoriality on all the waters inside, though that is
a point which has not apparently been decided. A line drawn from
the western boundary of Somerset (and in that case not from a
headland) to Worms Head, the most western part of Glamorgan,
measures about thirty geographical miles, and it is a markedly
oblique line. What is true of one county ought to be true of another,
and a much more natural line would be one of about twenty-three
geographical miles between Morte Point in Devon and Worms Head
in Glamorgan; or one still farther seawards between Hartland Point
in Devon and St Goven’s Head in Pembroke, which are about thirty-
eight geographical miles apart; but under common law the range of
vision has to be taken into account. It may be added that the whole
of the Bristol Channel within a line from Land’s End to Milford was
one of the “King’s Chambers” (see p. 122), the closing line being
nearly one hundred miles long; and that Continental publicists have
referred to it, probably from this circumstance, as being within
British jurisdiction.1085
Fig. 15.—The Bristol Channel.

Another case of the kind decided in a British court concerned


Conception Bay in Newfoundland, which is rather more than twenty
miles wide between the headlands and from forty to fifty miles in
length. It was decided by the Judicial Committee of the Privy Council
in 1877 that it was a British bay and part of the territorial waters of
Newfoundland. The decision was based partly on the configuration
of the bay, but mainly on the evidence that the British Government
had for a long time exercised dominion over it, which had been
acquiesced in by other nations, and the Legislature had by Acts of
Parliament declared it to be British territory.1086 Lord Blackburn, in
delivering judgment, said that there was a universal agreement
among writers on international jurisprudence that harbours,
estuaries, and bays, landlocked, belong to the territory of the nation
which possesses the shores round them, but no agreement existed
as to what is the rule to determine what is a “bay” for this purpose.
“It seems generally agreed,” he continued, “that where the
configuration and dimensions of the bay are such as to show that
the nation occupying the adjoining coasts also occupies the bay, it is
part of the territory,” most of the writers referring to defensibility
from the shore as the test of occupation. But the judgment was
founded on the principle above stated.

With regard to jurisdiction over foreigners in the waters along our


coasts, it is surprising that until quite recently there was no statutory
enactment or international agreement defining the extent of that
jurisdiction. Even in certain statutes in which the territorial waters
are specially mentioned their boundaries are not defined, Thus, the
provisions of the Foreign Enlistment Act of 1870,1087 which was
passed for purposes of neutrality in the war between France and
Germany, were declared by the second section to extend “to all the
dominions of Her Majesty, including the adjacent territorial waters”;
and the fourteenth section provided that any ship captured during
the war between other nations when Great Britain was neutral,
“within the territorial jurisdiction of Her Majesty, in violation of the
neutrality of this realm,” &c., would be illegal; yet, in the
interpretation clause no definition is given of the meaning or extent
of “the adjacent territorial waters.” A similar reluctance apparently to
fix a definite boundary to the territorial seas for all purposes has
been shown by the British Government on several occasions in
recent years—as, for example, in the Territorial Waters Jurisdiction
Act, and in the negotiations preceding the North Sea fishery
convention of 1882.1088

The statute just referred to was the outcome of a very important


case which was decided in the English courts in 1876, and raised
indirectly the whole question of the extent of the territorial sea
(apart from bays) and the nature of the jurisdiction over it. A
German ship, the Franconia, bound from Hamburg to the West
Indies, ran into a British ship, the Strathclyde, off Dover and within
two and a half miles from the English coast, whereby the Strathclyde
was sunk and a passenger drowned. The master, a German named
Keyn, was convicted of manslaughter in the Central Criminal Court,
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like