Skip to main content

fetchcode is a library to reliably fetch code via HTTP, FTP and version control systems.

Project description

FetchCode is a library to reliably fetch code via HTTP, FTP and version control systems. It can work using plain HTTP and FTP URLs, as well as Package URLs and version control (VCS) URLs as used in Python pip and as specified in SPDX Package Download Location

Homepage and support: https://github.com/aboutcode-org/fetchcode

Why FetchCode?

It is surprisingly difficult to have a simple API to consistently fetch code from package repositories, version control repositories and APIs: each site and each package manager has its own unique and peculiar ways. FetchCode goal is to abstract all these details and make it easy to fetch things reliably.

Development installation

Clone the repo:

git clone https://github.com/aboutcode-org/fetchcode

Then install all the requirements using this command (on POSIX):

./configure --dev

Running tests

To run test suite use:

pytest -vvs

Usage

Fetch a code archive and get a fetchcode.fetch.Response object back:

>>> from fetchcode import fetch
>>> f = fetch('https://github.com/aboutcode-org/fetchcode/archive/ab65b2e645c889887227ea49eb3332d885fd0a54.zip')
>>> f.location
'/tmp/tmp_cm02xsg'
>>> f.content_type
'application/zip'
>>> f.url
'https://github.com/aboutcode-org/fetchcode/archive/ab65b2e645c889887227ea49eb3332d885fd0a54.zip'

Fetch some package metadata and get a fetchcode.packagedcode_models.Package object back:

>>> from fetchcode import package
>>> list(package.info('pkg:rubygems/files'))
[Package(type='rubygems', namespace=None, name='files', version=None)]

Fetch a purl and get a fetchcode.fetch.Response object back:

>>> from fetchcode import fetch
>>> f = fetch('pkg:swift/github.com/Alamofire/Alamofire@5.4.3')
>>> f.location
'/tmp/tmp_cm02xsg'
>>> f.content_type
'application/zip'
>>> f.url
'https://github.com/Alamofire/Alamofire/archive/5.4.3.zip'

Ecosystems supported for fetching a purl from fetchcode:

  • alpm

  • apk

  • bitbucket

  • cargo

  • composer

  • conda

  • cpan

  • cran

  • deb

  • gem

  • generic

  • github

  • golang

  • hackage

  • hex

  • luarocks

  • maven

  • npm

  • nuget

  • pub

  • pypi

  • swift

License

  • SPDX-License-Identifier: Apache-2.0

Copyright (c) nexB Inc. and others.

Acknowledgements, Funding, Support and Sponsoring

This project is funded, supported and sponsored by:

  • Generous support and contributions from users like you!

  • the European Commission NGI programme

  • the NLnet Foundation

  • the Swiss State Secretariat for Education, Research and Innovation (SERI)

  • Google, including the Google Summer of Code and the Google Seasons of Doc programmes

  • Mercedes-Benz Group

  • Microsoft and Microsoft Azure

  • AboutCode ASBL

  • nexB Inc.

Europa logo EC DG Connect logo

NGI logo NLnet foundation logo

AboutCode logo nexB logo

This project was funded through the NGI0 Core Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101092990.

NGI Zero Core Logo https://nlnet.nl/project/VulnerableCode-enhancements/

This project was funded through the NGI0 Entrust Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101069594.

NGI Zero Entrust logo https://nlnet.nl/project/Back2source/

This project was funded through the NGI0 Core Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101092990.

NGI Zero Core Logo https://nlnet.nl/project/Back2source-next/

This project was funded through the NGI0 Entrust Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101069594.

NGI Zero Entrust logo https://nlnet.nl/project/purl2all/

Project details


Download files

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

Source Distribution

fetchcode-0.8.0.tar.gz (2.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fetchcode-0.8.0-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file fetchcode-0.8.0.tar.gz.

File metadata

  • Download URL: fetchcode-0.8.0.tar.gz
  • Upload date:
  • Size: 2.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fetchcode-0.8.0.tar.gz
Algorithm Hash digest
SHA256 411057eaa1da25d474b800709cbd0ee447b1ec3e7de0af92139e86f7e7c6cd5d
MD5 c82a0f389e4eaced139b40bc6fc3cddd
BLAKE2b-256 6166076b11b4d746c96655cbdf8dfc0fa1a45a2c0b13db18425147e7b237060c

See more details on using hashes here.

File details

Details for the file fetchcode-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: fetchcode-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fetchcode-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d694c785ace2ef491935c96c8c06d967f5bbd385e4a22cf759fa970fc64b5e2
MD5 4aa3df2907fbd0125c1a374b498c5576
BLAKE2b-256 fc5bbd98b8c1d34e8a2955a6e9e8f411266bf0dfec294d89d96b8b731e6f9587

See more details on using hashes here.

Supported by

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