https://github.com/clintmckenna/polymarketr
R Interface to Polymarket Prediction Markets
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.9%) to scientific vocabulary
Repository
R Interface to Polymarket Prediction Markets
Statistics
- Stars: 4
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
polymarketR
An R package to access, analyze, and visualize Polymarket event, market, and price data using public API endpoints.
Installation
This package is currently in development. To install the latest version from GitHub:
```r
Install devtools if you haven't already
install.packages("devtools")
Install polymarketR from GitHub
devtools::install_github("clintmckenna/polymarketR") ```
Usage Examples
```r
Load required libraries
library(polymarketR) library(ggplot2)
Search for an event by text (fuzzy search)
eventresults <- searchevents_text("new york city mayoral election")
Get event details by slug (use a known slug for stability)
Suppose we want to look at the 2025 New York City mayoral election. We can get the slug from the URL on Polymarket:
https://polymarket.com/event/new-york-city-mayoral-election
eventslug <- "new-york-city-mayoral-election" event <- geteventbyslug(event_slug)
Extract all markets for the event
markets <- geteventmarkets(event_slug)
Get price history for all Yes/No tokens in the event
Note: The interval and fidelity arguments are not always respected by the API—results may still be high-frequency.
By default, we exclude markets with zero liquidity.
history <- geteventpriceshistory(eventslug, interval = "max", fidelity = 1440)
Plot a time series of prices for all markets and outcomes
(Here, we facet by groupItemTitle for clarity)
ggplot(history, aes(x = datetime, y = price, color = outcome)) + geomline() + facetwrap(~ groupItemTitle, scales = "freey") + labs( title = "Polymarket Price History: New York City Mayoral Election", x = "Date", y = "Price (Probability)", color = "Outcome" ) + thememinimal()
```

Recently Added Functions
```r
Get the best bid/ask price for a token (use a token_id from markets tibble)
token <- markets$yestokenid[1] price <- getprice(tokenid = token, side = "buy")
Get the order book for a token (long format with bids/asks)
book <- getbook(tokenid = token, side = "both")
Get all current positions for a user
address <- "0x44c1dfe43260c94ed4f1d00de2e1f80fb113ebc1" positions <- get_position(user = address)
Get on-chain activity for a user (trades, splits, merges, etc.)
activity <- getuseractivity(user = address, limit = 20)
Get top holders for a market token (by conditionId)
conId <- markets$conditionId[1] holders <- get_holders(market = conId, limit = 10)
Get the total USD value of a user's holdings (across all or specific markets)
userholdings <- getuser_value(user = address)
```
Notes: - Not all events/markets will have price history available for all tokens. - The interval parameter may not always be honored exactly by the API; you may receive lower- or higher-frequency data. Still trying to figure out a solution for this. - All package functions return tibbles for easy manipulation with dplyr/tidyverse tools.
Thanks and feel free to suggest any changes or improvements!
Owner
- Name: Clint McKenna
- Login: clintmckenna
- Kind: user
- Location: Ann Arbor, MI
- Company: University of Michigan
- Repositories: 0
- Profile: https://github.com/clintmckenna
Graduate Student in Social Psychology
GitHub Events
Total
- Watch event: 1
- Push event: 3
- Create event: 1
Last Year
- Watch event: 1
- Push event: 3
- Create event: 1
Dependencies
- R >= 3.5.0 depends
- httr * imports
- jsonlite * imports
- tibble * imports
- dplyr * suggests
- testthat * suggests