Skip to main content

A Python library to consume the RavenPack API.

API documentation.

Installation

pip install ravenpackapi

About

The Python client helps managing the API calls to the RavenPack dataset server in a Pythonic way, here are some examples of usage, you can find more in the tests.

Usage

In order to be able to use the RavenPack API you will need an API KEY. If you don’t already have one please contact your customer support representative.

To begin using the API you will need to instantiate an API object that will deal with the API calls.

Using your RavenPack API KEY, you can either set the RP_API_KEY environment variable or set it in your code:

from ravenpackapi import RPApi

api = RPApi(api_key="YOUR_API_KEY")

Creating a new dataset

To create a dataset you can call the create_dataset method of the API with a Dataset instance.

from ravenpackapi import Dataset

ds = api.create_dataset(
    Dataset(
        name="New Dataset",
        filters={
            "relevance": {
                "$gte": 90
            }
        },
    )
)
print("Dataset created", ds)

Getting data from the datasets

In the API wrapper, there are several models that maybe used for interacting with data.

Here is how you may get a dataset definition for a pre-existing dataset

# Get the dataset description from the server, here we use 'us30'
# one of RavenPack public datasets with the top30 companies in the US

ds = api.get_dataset(dataset_id='us30')

Downloads: json

The json endpoint is useful for asking data synchronously, optimized for small requests, if you need to download big data chunks you may want to use the asynchronous datafile endpoint instead.

data = ds.json(
    start_date='2018-01-05 18:00:00',
    end_date='2018-01-05 18:01:00',
)

for record in data:
    print(record)

Json queries are limited to

  • granular datasets: 10,000 records

  • indicator datasets: 500 entities, timerange 1 year, lookback window 1 year

Downloads: datafile

For bigger requests the datafile endpoint can be used to prepare a datafile asynchronously on the RavenPack server for later retrieval.

Requesting a datafile, will give you back a job object, that will take some time to complete.

job = ds.request_datafile(
    start_date='2018-01-05 18:00:00',
    end_date='2018-01-05 18:01:00',
)

with open('output.csv') as fp:
    job.save_to_file(filename=fp.name)

Streaming real-time data

It is possible to subscribe to a real-time stream for a dataset.

Once you create a streaming connection to the real-time feed with your dataset, you will receive analytics records as soon as they are published.

It is suggested to handle possible disconnection with a retry policy. You can find a real-time streaming example here.

The Result object handles the conversion of various fields into the appropriate type, i.e. record.timestamp_utc will be converted to datetime

Entity mapping

The entity mapping endpoint allow you to find the RP_ENTITY_ID mapped to your universe of entities.

universe = [
    "RavenPack",
    {'ticker': 'AAPL'},
    {  # Amazon, specifying various fields
        "client_id": "12345-A",
        "date": "2017-01-01",
        "name": "Amazon Inc.",
        "entity_type": "COMP",
        "isin": "US0231351067",
        "cusip": "023135106",
        "sedol": "B58WM62",
        "listing": "XNAS:AMZN"
    },

]
mapping = api.get_entity_mapping(universe)

# in this case we match everything
assert len(mapping.matched) == len(universe)
assert [m.name for m in mapping.matched] == [
    "RavenPack Ltd.",
    "Apple Inc.",
    "Amazon.com Inc."
]

Entity reference

The entity reference endpoint give you all the available information for an Entity given the RP_ENTITY_ID

ALPHABET_RP_ENTITY_ID = '4A6F00'

references = api.get_entity_reference(ALPHABET_RP_ENTITY_ID)

# show all the names over history
for name in references.names:
    print(name.value, name.start, name.end)

# print all the ticket valid today
for ticker in references.tickers:
    if ticker.is_valid():
        print(ticker)

Training Datasets

Analyse your own content using RavenPack’s proprietary NLP technology.

The API for analyzing your internal content is still in beta and may change in the future. You can request an early access and see an example of usage here.

Accessing the low-level requests

RavenPack API wrapper is using the requests library to do HTTPS requests, you can set common requests parameters to all the outbound calls by setting the common_request_params attribute.

For example, to disable HTTPS certificate verification and to setup your internal proxy:

api = RPApi()
api.common_request_params.update(
    dict(
        proxies={'https': 'http://your_internal_proxy:9999'},
        verify=False,
    )
)

# use the api to do requests

PS. For setting your internal proxies, requests will honor the HTTPS_PROXY environment variable.

Metadata

Release files for ravenpackapi 1.1.6

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

Source distribution (sdist)

Source distribution for ravenpackapi 1.1.6
File Size Uploaded
ravenpackapi-1.1.6.tar.gz 47.4 kB Details

Release files / ravenpackapi-1.1.6.tar.gz

Download URL ravenpackapi-1.1.6.tar.gz
Size 47.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c279d34eb4e1f791919c291e798aaa3b5a68c55d2aa42b12c8d5a391813211d3
BLAKE2b-256 checksum
How to use checksums
fc09d8c2026a77ff4adfc5c4c1807aa671cb173345c4858e6589613d474608ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

1.1.6 This release

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.60

1 release file

1.0.59

1 release file

1.0.58

1 release file

1.0.57

1 release file

1.0.56

1 release file

1.0.55

1 release file

1.0.54

1 release file

1.0.53

1 release file

1.0.52

1 release file

1.0.51

1 release file

1.0.50

1 release file

1.0.49

1 release file

1.0.48

1 release file

1.0.47

1 release file

1.0.45

1 release file

1.0.44

1 release file

1.0.43

1 release file

1.0.42

1 release file

1.0.41

1 release file

1.0.40

1 release file

1.0.38

1 release file

1.0.37

1 release file

1.0.36

1 release file

1.0.35

1 release file

1.0.34

1 release file

1.0.33

1 release file

1.0.32

1 release file

1.0.31

1 release file

1.0.30

1 release file

1.0.29

1 release file

1.0.28

1 release file

1.0.27

1 release file

1.0.26

1 release file

1.0.25

1 release file

1.0.24

1 release file

1.0.23

1 release file

1.0.22

1 release file

1.0.21

1 release file

1.0.20

1 release file

1.0.19

1 release file

1.0.18

1 release file

1.0.17

1 release file

1.0.16

1 release file

1.0.15

1 release file

1.0.14

1 release file

1.0.13

1 release file

1.0.12

1 release file

1.0.11

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.1.0

1 release file

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