Skip to content

Commit 1402c67

Browse files
Theodore Marescauxdehidehidehi
authored andcommitted
README: Added installation info and example usage.
1 parent 3bf94a0 commit 1402c67

File tree

2 files changed

+61
-15
lines changed

2 files changed

+61
-15
lines changed

README.md

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,66 @@
11
# OpenSea Python API Wrapper
2+
23
A convenient package for interacting with the OpenSea API; which allows for asynchronous retrieval of asset data from the OpenSea marketplace (https://opensea.io/).
34

4-
# Installation requires:
5-
* Python 3.9 or greater (https://www.python.org/downloads/source/)
6-
* Packages specified in: requirements.txt
5+
# Installation requires
6+
7+
- Python 3.9 or greater (https://www.python.org/downloads/source/)
8+
- Packages specified in: requirements.txt
9+
10+
# Installation
11+
12+
```console
13+
git clone https://github.com/dehidehidehi/opensea-python-wrapper.git
14+
```
15+
```console
16+
cd opensea-python-wrapper
17+
python setup.py install
18+
```
719

820
# Warning about the dev branch
9-
* Do not expect the dev branch to be stable or complete.
10-
* There is no documentation yet. To get a sense on how the package works, have a look at the endpoint classes in the open_sea_v1 folder. You'll probably want to instanciate an endpoint class, and call it's methods.
11-
* There will be non backwards-compatible pushes and commit squashes on the dev branch.
21+
22+
- Do not expect the dev branch to be stable or complete.
23+
- There is no documentation yet. To get a sense on how the package works, have a look at the endpoint classes in the open_sea_v1 folder. You'll probably want to instanciate an endpoint class, and call it's methods.
24+
- There will be non backwards-compatible pushes and commit squashes on the dev branch.
25+
26+
# Example usage
27+
Fetching all successful sales using the EventsEndpoint.
28+
Check the class for more info on additional filtering parameters.
29+
30+
```console
31+
from datetime import datetime, timedelta
32+
from open_sea_v1.endpoints.client import ClientParams
33+
from open_sea_v1.endpoints.events import EventType, AuctionType, EventsEndpoint
34+
35+
36+
asset_contract_address: str = "example_contract_string_to_replace"
37+
after = datetime.now() - timedelta(days=5)
38+
client_params = ClientParams()
39+
40+
endpoint = EventsEndpoint(
41+
client_params=client_params,
42+
asset_contract_address=asset_contract_address,
43+
occurred_before=None,
44+
occurred_after=after,
45+
event_type=EventType.SUCCESSFUL,
46+
)
47+
48+
flattened_events_pages: list = endpoint.get_parsed_pages()
49+
unflattened_events_pages: list[list] = endpoint.get_parsed_pages(flat=False)
50+
```
1251

1352
# About the documentation
14-
* OpenSea API V1 Documentation: https://docs.opensea.io/reference/
15-
* Anonymous API usage is limited to 2 queries per second.
53+
54+
- OpenSea API V1 Documentation: https://docs.opensea.io/reference/
55+
- Anonymous API usage is limited to 2 queries per second.
1656

1757
# API Key
18-
* Request an API key here: https://docs.opensea.io/reference/request-an-api-key
19-
* If you have an API key:
20-
* Requests are automatically throttled to 20 queries per second.
21-
* The package will automatically use the system variable OPENSEA_API_KEY as the API key.
22-
* If this system variable is not found, you must pass the API key in the ClientParam instance for each Endpoint instance.
58+
Request an API key here: https://docs.opensea.io/reference/request-an-api-key
59+
60+
If you have an API key:
61+
- Requests are automatically throttled to 20 queries per second.
62+
- The package will automatically use the system variable OPENSEA_API_KEY as the API key.
63+
```console
64+
export OPENSEA_API_KEY="<YOUR API KEY>"
65+
```
66+
If this system variable is not found, you must pass the API key in the ClientParam instance for each Endpoint instance.

open_sea_v1/helpers/ether_converter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class EtherUnit(IntEnum):
77
"""
88
Ether sub-units quantified in Wei.
99
"""
10+
1011
WEI = 1
1112
KWEI = 1_000
1213
MWEI = 1_000_000
@@ -19,8 +20,9 @@ class EtherUnit(IntEnum):
1920
@dataclass
2021
class EtherConverter:
2122
"""
22-
Convenience class whic helps convert Ether and it's sub-units (gwei, twei etc.) into other sub-units.
23+
Convenience class that helps convert Ether and its sub-units (gwei, twei etc.) into other sub-units.
2324
"""
25+
2426
quantity: Union[str, int, float]
2527
unit: EtherUnit
2628

@@ -59,4 +61,4 @@ def kwei(self):
5961

6062
@property
6163
def wei(self):
62-
return self.convert_to(EtherUnit.WEI)
64+
return self.convert_to(EtherUnit.WEI)

0 commit comments

Comments
 (0)