|
1 | 1 | # OpenSea Python API Wrapper |
| 2 | + |
2 | 3 | A convenient package for interacting with the OpenSea API; which allows for asynchronous retrieval of asset data from the OpenSea marketplace (https://opensea.io/). |
3 | 4 |
|
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 | + ``` |
7 | 19 |
|
8 | 20 | # 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 | +``` |
12 | 51 |
|
13 | 52 | # 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. |
16 | 56 |
|
17 | 57 | # 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. |
0 commit comments