Skip to main content

arcp (Archive and Package) URI parser and generator

Project description

Create/parse arcp (Archive and Package) URIs.

Documentation Status


arcp provides functions for creating arcp URIs, which can be used for identifying or parsing hypermedia files packaged in an archive or package, like a ZIP file.

arcp URIs can be used to consume or reference hypermedia resources bundled inside a file archive or an application package, as well as to resolve URIs for archive resources within a programmatic framework.

This URI scheme provides mechanisms to generate a unique base URI to represent the root of the archive, so that relative URI references in a bundled resource can be resolved within the archive without having to extract the archive content on the local file system.

An arcp URI can be used for purposes of isolation (e.g. when consuming multiple archives), security constraints (avoiding “climb out” from the archive), or for externally identiyfing sub-resources referenced by hypermedia formats.

  • arcp://uuid,32a423d6-52ab-47e3-a9cd-54f418a48571/doc.html

  • arcp://uuid,b7749d0b-0e47-5fc4-999d-f154abe68065/pics/

  • arcp://ni,sha-256;F-34D4TUeOfG0selz7REKRDo4XePkewPeQYtjL3vQs0/

  • arcp://name,

The different forms of URI authority in arcp URIs can be used depending on which uniqueness constraints to apply when addressing an archive. See the arcp specification (draft-soilandreyes-arcp) for details.

Note that this library only provides mechanisms to generate and parse arcp URIs, and do not integrate with any particular archive or URL handling modules like zipfile or urllib.request.


© 2018-2020 Stian Soiland-Reyes <>, The University of Manchester, UK

Licensed under the Apache License, version 2.0 <>, see the file LICENSE.txt for details.


Source code: <>

Feel free to raise a pull request at <> or an issue at <>.

Submitted contributions are assumed to be covered by section 5 of the Apache License 2.0.


You will need Python 2.7, Python 3.4 or later (Recommended: 3.6).

If you have pip, then the easiest is normally to install from <> using:

pip install arcp

If you want to install manually from this code base, then try:

python install


For full documentation, see <> or use help(arcp)

This module provides functions for creating arcp URIs, which can be used for identifying or parsing hypermedia files packaged in an archive or package, like a ZIP file:: python

>>> from arcp import *
>>> arcp_random()
>>> arcp_random("/foaf.ttl", fragment="me")
>>> arcp_hash(b"Hello World!", "/folder/")
>>> arcp_location("", "/file.txt")

arcp URLs can be used with urllib.parse, for instance using urljoin to resolve relative references:

>>> css = arcp.arcp_name("", "css/style.css")
>>> urllib.parse.urljoin(css, "../fonts/foo.woff")

In addition this module provides functions that can be used to parse arcp URIs into its constituent fields:: python

>>> is_arcp_uri("arcp://uuid,b7749d0b-0e47-5fc4-999d-f154abe68065/file.txt")
>>> is_arcp_uri("")
>>> u = parse_arcp("arcp://uuid,b7749d0b-0e47-5fc4-999d-f154abe68065/file.txt")
>>> u.path
>>> u.prefix
>>> u.uuid
>>> u.uuid.version
>>> parse_arcp("arcp://ni,sha-256;f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk/folder/").hash
('sha-256', '7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069')

The object returned from parse_arcp is similar to ParseResult from urlparse, but contains additional properties prefix, uuid, ni, hash and name, some of which will be None depending on the arcp prefix.

The function arcp.parse.urlparse can be imported as an alternative to urllib.parse.urlparse. If the scheme is arcp then the extra arcp fields like prefix, uuid, hash and name are available as from parse_arcp, otherwise the output is the same as from regular urlparse:: python

>>> from arcp.parse import urlparse
>>> urlparse("arcp://ni,sha-256;f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk/folder/soup;sads")
   hash=('sha-256', '7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069',
>>> urlparse("")
ParseResult(scheme='http', netloc='', path='/help', params='',
  query='q=a', fragment='')

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arcp-0.2.1.tar.gz (22.1 kB view hashes)

Uploaded source

Built Distribution

arcp-0.2.1-py2.py3-none-any.whl (15.8 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page