@@ -3,18 +3,96 @@ RavenPack API - Python client
33
44A Python library to consume the [ RavenPack API] ( https://www.ravenpack.com ) .
55
6- [ Access the documention here .] ( https://www.ravenpack.com/support/ )
6+ [ API documention.] ( https://www.ravenpack.com/support/ )
77
88## Installation
99
1010 pip install ravenpackapi
1111
12- ## Basic usage
12+ ## About
1313
1414The Python client helps managing the API calls to the RavenPack dataset server
1515 in a Pythonic way, here are some examples of usage, you can find more in the tests.
1616
17- To use the API you need to have a RavenPack API KEY.
18-
1917This is still a work in progress: while the API is stable we are still working
2018on this Python wrapper.
19+
20+ ## Usage
21+
22+ First, you'll need an API object that will deal with the API calls.
23+
24+ You will need a RavenPack API KEY, you can set the ` RP_API_KEY ` environment variable
25+ or set it in your code:
26+
27+ ``` python
28+ from ravenpackapi import RPApi
29+
30+ api = RPApi(api_key = " YOUR_API_KEY" )
31+ ```
32+
33+ ### Getting data from the datasets
34+
35+ There are several models to deal with data, the datasets are a cut of the RavenPack data
36+ they are defined with a set of filters and a set of fields.
37+
38+ ``` python
39+ # Get the dataset description from the server, here we use 'us30'
40+ # one of RavenPack public datasets with the top30 companies in the US
41+
42+ ds = api.get_dataset(dataset_id = ' us30' )
43+ ```
44+ #### Downloads: json
45+
46+ ``` python
47+ data = ds.json(
48+ start_date = ' 2018-01-05 18:00:00' ,
49+ end_date = ' 2018-01-05 18:01:00' ,
50+ )
51+
52+ for record in data:
53+ print (record)
54+ ```
55+
56+ The json endpoint is handy for asking data synchronously, if you need to download big
57+ data chunks you may want to use the asynchronous datafile endpoint instead.
58+
59+ Json queries are limited to
60+ * granular datasets: 10,000 records
61+ * indicator datasets: 500 entities, timerange 1Y, lookback 1Y
62+
63+ #### Downloads: datafile
64+
65+ For bigger requests the datafile endpoint can be used.
66+
67+ Requesting a datafile, will give you back a job promise, that will take some time
68+ to complete.
69+
70+ ``` python
71+ job = ds.request_datafile(
72+ start_date = ' 2018-01-05 18:00:00' ,
73+ end_date = ' 2018-01-05 18:01:00' ,
74+ )
75+
76+ with open (' output.csv' ) as fp:
77+ job.save_to_file(filename = fp.name)
78+ ```
79+
80+ ### Entity reference
81+
82+ The entity reference endpoint give you all the available information over an Entity
83+ starting from the RP_ENTITY_ID
84+
85+ ``` python
86+ ALPHABET_RP_ENTITY_ID = ' 4A6F00'
87+
88+ references = api.get_entity_reference(ALPHABET_RP_ENTITY_ID )
89+
90+ # show all the names over history
91+ for name in references.names:
92+ print (name.value, name.start, name.end)
93+
94+ # print all the ticket valid today
95+ for ticker in references.tickers:
96+ if ticker.is_valid():
97+ print (ticker)
98+ ```
0 commit comments