Skip to content

Commit

Permalink
Merge pull request #61 from Polymarket/feat/live-activity-markets-events
Browse files Browse the repository at this point in the history
Adding support for the new events endpoint
  • Loading branch information
poly-rodr authored Jul 17, 2023
2 parents 68d0d71 + 0f911c4 commit c019714
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
27 changes: 27 additions & 0 deletions examples/get_market_trades_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os

from py_clob_client.client import ClobClient
from py_clob_client.clob_types import ApiCreds
from dotenv import load_dotenv
from py_clob_client.constants import MUMBAI

load_dotenv()


def main():
host = "http://localhost:8080"
key = os.getenv("PK")
creds = ApiCreds(
api_key=os.getenv("CLOB_API_KEY"),
api_secret=os.getenv("CLOB_SECRET"),
api_passphrase=os.getenv("CLOB_PASS_PHRASE"),
)
chain_id = MUMBAI
client = ClobClient(host, key=key, chain_id=chain_id, creds=creds)

print(client.get_market_trades_events("condition_id"))

print("Done!")


main()
7 changes: 7 additions & 0 deletions py_clob_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
GET_MARKET,
GET_SAMPLING_SIMPLIFIED_MARKETS,
GET_SAMPLING_MARKETS,
GET_MARKET_TRADES_EVENTS,
)
from .clob_types import (
ApiCreds,
Expand Down Expand Up @@ -523,3 +524,9 @@ def get_market(self, condition_id):
Get a market by condition_id
"""
return get("{}{}{}".format(self.host, GET_MARKET, condition_id))

def get_market_trades_events(self, condition_id):
"""
Get the market's trades events by condition id
"""
return get("{}{}{}".format(self.host, GET_MARKET_TRADES_EVENTS, condition_id))
1 change: 1 addition & 0 deletions py_clob_client/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
GET_SIMPLIFIED_MARKETS = "/simplified-markets"
GET_MARKETS = "/markets"
GET_MARKET = "/markets/"
GET_MARKET_TRADES_EVENTS = "/live-activity/events/"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="py_clob_client",
version="0.8.0",
version="0.9.0",
author="Polymarket Engineering",
author_email="[email protected]",
maintainer="Polymarket Engineering",
Expand Down

0 comments on commit c019714

Please sign in to comment.