Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Python : Simple Crypto currencies scrapper

This is a simple module that retrieve instant crypto currencies values in BTC and USD from coin360.com and coinmarketcap apis

How to use

First install the package

pip install cryptocurrencies_scraper

Basic usage

from cryptocurrencies_scraper.CurrencyService import Manager
manager = Manager() # Create a new instance of the Manager
manager.update() # Ask the manager to update all currencies values

manager.all_currencies() # returns a dict that contain the currency name and symbol as key and currency information as a list
manager.get_curency('btc') # return the list of currency values retrived for bitcoin using symbol
manager.get_curency('bitcoin') # return the list of currency values retrived for bitcoin using name

Add your own scraper

A scraper should extends the CurrentPriceInterface. Here is a basic scheme for a new scraper

class MySourceForCurrencies(CurrentPriceInterface):
    instance = None
    URL = 'https://api.mysource.com/v1/ticker/?limit=3000'
    NAME = "mysource.com"

    @classmethod
    def get_instance(cls) -> 'CurrenciesFromCoinMarketCap':
        if cls.instance is None:
            cls.instance = MySourceForCurrencies()
        return cls.instance

    def __init__(self):
        super().__init__()

    def update_currency_list(self):
        self.process_data(requests.get(self.URL).json())

    def process_data(self, json_data: json) -> None:
        # Manipulate the the json to be Currency "parsable"
        c = Currency.parse_json(json_data, self.NAME)
        #When parsed, add it to the index 
        NameIndexes.get_instance().add_to_index(c)
        return None

In order for your scraper to be working you need to add it to the manager

from cryptocurrencies_scraper.CurrencyService import Manager
manager = Manager()
manager.add_source(MySourceForCurrencies.get_instance())

# you can also remove a source
manager.remove_source(MySourceForCurrencies.NAME)

Then on each manager.update() call your scraper will be called and currencies added to the Index

NameIndex

This class is used internally to index all currencies. When a new currency is added, it will be grouped by the symbol and the name (symbol upper, name lower case)

The only useful method is NameIndexes.get_instance().add_to_index(currency). On each update, it get completlly cleared from all old values.

Currency

This is the object that represent one currency here is the structure

 {
    "symbol" : "BTC",
    "name" : "Bitcoin",
    "valueUSD" : 5513,
    "valueBTC": 1,
    "lastUpdate" : 1566531513813,
    "source" : "coin360.com",
    "changes" : {
        "7d": -1,
        "24h": -5,
        "1h": -10
    }
 }

Metadata

Release files for cryptocurrencies-scraper 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cryptocurrencies-scraper 0.0.3
File Size Uploaded Provenance
cryptocurrencies_scraper-0.0.3.tar.gz 5.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cryptocurrencies-scraper 0.0.3
File Interpreter ABI Platform
cryptocurrencies_scraper-0.0.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 10.8 kB

Release files / cryptocurrencies_scraper-0.0.3.tar.gz

Download URL cryptocurrencies_scraper-0.0.3.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
b090647eca42deeb4315350395e66e6c5e015ae6f9bab61ad9eb5ea9239f7e4c
BLAKE2b-256 checksum
How to use checksums
da115a0dfe3b2fef93c3628d0864c891426745df139a2e56b821788dd5516a7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

Release files / cryptocurrencies_scraper-0.0.3-py2.py3-none-any.whl

Download URL cryptocurrencies_scraper-0.0.3-py2.py3-none-any.whl
Size 5.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4dbcdee91ce21d7330fd6dcf1535294a81d25418f92f39e6533d3e827890035e
BLAKE2b-256 checksum
How to use checksums
d68e70230d216448000a302539e13432232525c8f2c8ad0bc677c04dfe98f79a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

Security for cryptocurrencies-scraper 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page