Home

Awesome

graphsense-python

GraphSense API provides programmatic access to various ledgers' addresses, entities, blocks, transactions and tags for automated and highly efficient forensics tasks.

This Python package is automatically generated by the OpenAPI Generator project:

Requirements.

Python >= 3.6

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/graphsense/graphsense-python.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/graphsense/graphsense-python.git)

Then import the package:

import graphsense

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import graphsense

Getting Started

Please follow the installation procedure and then run the following:


import time
import graphsense
from pprint import pprint
from graphsense.api import addresses_api
from graphsense.model.address import Address
from graphsense.model.address_tags import AddressTags
from graphsense.model.address_txs import AddressTxs
from graphsense.model.entity import Entity
from graphsense.model.height import Height
from graphsense.model.links import Links
from graphsense.model.neighbor_addresses import NeighborAddresses
from graphsense.model.tag_summary import TagSummary
# Defining the host is optional and defaults to https://api.ikna.io
# See configuration.py for a list of all supported configuration parameters.
configuration = graphsense.Configuration(
    host = "https://api.ikna.io"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: api_key
configuration.api_key['api_key'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api_key'] = 'Bearer'


# Enter a context with an instance of the API client
with graphsense.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = addresses_api.AddressesApi(api_client)
    currency = "btc" # str | The cryptocurrency code (e.g., btc)
    address = "1Archive1n2C579dMsAu3iC6tWzuQJz8dN" # str | The cryptocurrency address
    include_actors = True # bool | Whether to include information about the actor behind the address (optional) (default to True)

    try:
        # Get an address
        api_response = api_instance.get_address(currency, address, include_actors=include_actors)
        pprint(api_response)
    except graphsense.ApiException as e:
        print("Exception when calling AddressesApi->get_address: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.ikna.io

ClassMethodHTTP requestDescription
AddressesApiget_addressGET /{currency}/addresses/{address}Get an address
AddressesApiget_address_entityGET /{currency}/addresses/{address}/entityGet the entity of an address
AddressesApiget_tag_summary_by_addressGET /{currency}/addresses/{address}/tag_summaryGet attribution tag summary for a given address
AddressesApilist_address_linksGET /{currency}/addresses/{address}/linksGet outgoing transactions between two addresses
AddressesApilist_address_neighborsGET /{currency}/addresses/{address}/neighborsGet an address's neighbors in the address graph
AddressesApilist_address_txsGET /{currency}/addresses/{address}/txsGet all transactions an address has been involved in
AddressesApilist_tags_by_addressGET /{currency}/addresses/{address}/tagsGet attribution tags for a given address
BlocksApiget_blockGET /{currency}/blocks/{height}Get a block by its height
BlocksApiget_block_by_dateGET /{currency}/block_by_date/{date}Get the closest blocks given a timestamp
BlocksApilist_block_txsGET /{currency}/blocks/{height}/txsGet block transactions
BulkApibulk_csvPOST /{currency}/bulk.csv/{operation}Get data as CSV in bulk
BulkApibulk_jsonPOST /{currency}/bulk.json/{operation}Get data as JSON in bulk
EntitiesApiget_entityGET /{currency}/entities/{entity}Get an entity
EntitiesApilist_address_tags_by_entityGET /{currency}/entities/{entity}/tagsGet address tags for a given entity
EntitiesApilist_entity_addressesGET /{currency}/entities/{entity}/addressesGet an entity's addresses
EntitiesApilist_entity_linksGET /{currency}/entities/{entity}/linksGet transactions between two entities
EntitiesApilist_entity_neighborsGET /{currency}/entities/{entity}/neighborsGet an entity's direct neighbors
EntitiesApilist_entity_txsGET /{currency}/entities/{entity}/txsGet all transactions an entity has been involved in
EntitiesApisearch_entity_neighborsGET /{currency}/entities/{entity}/searchSearch deeply for matching neighbors
GeneralApiget_statisticsGET /statsGet statistics of supported currencies
GeneralApisearchGET /searchReturns matching addresses, transactions and labels
RatesApiget_exchange_ratesGET /{currency}/rates/{height}Returns exchange rate for a given height
TagsApiget_actorGET /tags/actors/{actor}Returns an actor given its unique id or (unique) label
TagsApiget_actor_tagsGET /tags/actors/{actor}/tagsReturns the address tags for a given actor
TagsApilist_address_tagsGET /tagsReturns address tags associated with a given label
TagsApilist_conceptsGET /tags/taxonomies/{taxonomy}/conceptsReturns the supported concepts of a taxonomy
TagsApilist_taxonomiesGET /tags/taxonomiesReturns the supported taxonomies
TokensApilist_supported_tokensGET /{currency}/supported_tokensReturns a list of supported token (sub)currencies
TxsApiget_spending_txsGET /{currency}/txs/{tx_hash}/spendingReturns in which other transaction's outputs the asked transaction spent. Think backwards references is the transaction graph. This endpoint is only available for utxo like currencies.
TxsApiget_spent_in_txsGET /{currency}/txs/{tx_hash}/spent_inReturns in which other transactions, outputs from the asked transaction are spent. Think forward references in the transaction graph. This endpoint is only available for utxo like currencies.
TxsApiget_txGET /{currency}/txs/{tx_hash}Returns details of a specific transaction identified by its hash
TxsApiget_tx_ioGET /{currency}/txs/{tx_hash}/{io}Returns input/output values of a specific transaction identified by its hash
TxsApilist_token_txsGET /{currency}/token_txs/{tx_hash}Returns all token transactions in a given transaction

Documentation For Models

Documentation For Authorization

api_key

Examples

In ./examples you can find example Python scripts and Jupyter notebooks demonstrating how to use the GraphSense Python API. Please Follow these setup instructions to run them:

Setup a Python environment with Anaconda:

conda env create -f environment.yml
conda activate graphsense-python

Copy the config temp file and enter your Iknaio API key

cp config.json.tmp config.json
vi config.json

Run the jupyter notebooks

jupyter notebook

Generation from OpenAPI specification

This python package has been generated from Graphsense's OpenAPI specification hosted by Iknaio Cryptoasset Analytics GmbH using this command:

make GS_REST_SERVICE_URL="https://api.ikna.io" generate-openapi-client